immutability - Understand Scala immutable Map behaviour -


i used scala immutable map per below.

val d = "4.55"

  1. this working fine.

    val  properties = map("title"->"title" , "value" -> d ) 
  2. its convert [string , anyref] [string, any]

    val  properties = map("title"->"title" , "value" -> d.todouble ) 
  3. cant convert double object , runtime error

    val  properties:map[string,object] = map("title"->"title" , "value" -> d.todouble ) 

    why object cant accept double?

  4. 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

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -