mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-11 01:04:10 +02:00
Added arrays and maps
This commit is contained in:
@@ -51,3 +51,16 @@ val sq = (x:Int) => x * x
|
|||||||
|
|
||||||
sq(10) // Gives you this: res33: Int = 100. The result is the Int with a value 100
|
sq(10) // Gives you this: res33: Int = 100. The result is the Int with a value 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Data structures
|
||||||
|
|
||||||
|
val a = Array(1, 2, 3, 5, 8, 13)
|
||||||
|
a(0)
|
||||||
|
a(3)
|
||||||
|
a(21) // Throws an exception
|
||||||
|
|
||||||
|
val m = Map("fork" -> "tenedor", "spoon" -> "cuchara", "knife" -> "cuchillo")
|
||||||
|
m("fork")
|
||||||
|
m("spoon")
|
||||||
|
m("bottle") // Throws an exception
|
Reference in New Issue
Block a user