It is interesting how different languages approach towards a given problem.
Let's have a look at how different languages react while trying to read a key from dictionary
Java
map.get('key_that_does_not_exist')
=> null
Ruby
Let's have a look at how different languages react while trying to read a key from dictionary
Java
map.get('key_that_does_not_exist')
=> null
Ruby
map['key_that_does_not_exist']
=> nil
Python
|
Scala
val x = Map("a" -> "1”)
x("key_that_does_not_exist”) // Throws exception
x.get("key_that_does_not_exist”) // None