mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added arrays and maps
This commit is contained in:
parent
2e7c3ba085
commit
7673ae8a6d
@ -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
|
||||
|
||||
|
||||
|
||||
// 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
|
Loading…
Reference in New Issue
Block a user