On Fri, Aug 3, 2012 at 9:07 PM, Marek Broda <
broda...@gmail.com> wrote:
> Is there [...] some way to automatically box scala
> Any value?
x.asInstanceOf[AnyRef]
Idea: Scala has `box` methods on the companion objects for all the
specific AnyVal types (Int.box, Double.box, and so on) it, so it would
be nice if the standard library provided `Any.box` as well, as a
shorter way of writing the above.
Why add a method that doesn't add a new capability? Because normally
the presence of `asInstanceOf` means you're doing an end run around
the type system. But boxing an Any is perfectly typesafe, so Scala
ought not to force me to drop down to asInstanceOf, IMO.
--
Seth Tisue | Northwestern University |
http://tisue.net
lead developer, NetLogo:
http://ccl.northwestern.edu/netlogo/