immutability - Understand Scala immutable Map behaviour -
i used scala immutable map per below.
val d = "4.55"
this working fine.
val properties = map("title"->"title" , "value" -> d )
its convert [string , anyref] [string, any]
val properties = map("title"->"title" , "value" -> d.todouble )
cant convert double object , runtime error
val properties:map[string,object] = map("title"->"title" , "value" -> d.todouble )
why object cant accept double?
working fine.
val properties:map[string,object] = map("title"->"title" , "value" -> d.todouble.asinstanceof[object] )
cant understand 4 scenario of immutable map behaviour.
most important of all: scala has no primitive types java do.
scala's double class, inherit anyval, has it's own methods
but java's object the base class of reference types, aka...class
so, did here using object base class of double.
in opinion,
scala's anyref corresponding type java's object.
scala's anyval corresponding type java's primitive types.
Comments
Post a Comment