groostav
02/23/2017, 11:47 PMval x by map
was that it would primarily operate on objects of disparate types (a le Javascript), thus I think the by map
idea was largely aimed as a shim for dynamic languages into kotlin.
But I could agree with your assestment, especially when we have access to raw types. Perhaps it would be better if we had something like
val map: Map<String, Any?> = ...
val name:String by map //compiler error: cannot use `Map<String, Any?> as delegate for `val name: String` expected Value type to be String but was Any?
val name: String by (map as Map) //compiler warning: unchecked raw type cast: Map<String, Any?> to Map
val name: String by @SuppressWarnings("unchecked")(map as Map) //compiles without issue
unfortunately its a moot point since any change would break backwards compatibility in a pretty big waynkiesel
02/24/2017, 12:27 AMgroostav
02/24/2017, 5:27 AMval name: String by map.safe()
, with safe
being an extension method in the std:lib