Rickard Nilsson | 22 Dec 15:34
Picon

Re: Scala Object Notation ( SCON? )

Another related thing I wish for is some lightweight
syntax for using case classes as immutable records,
(in Haskell-style, among others).

So following your example I would like to do:

   val p = Person {
     name = "Peter"
     age = 20
     ...
   }

   val q = p { name = "Rickard" }

where p gets all the attributes from p, with the
name updated. I would find this very useful. Any
suggestions for doing something similar without
any new special syntax?

   / Rickard

On Sat, 22 Dec 2007 14:48:53 +0100, Andrés Testi  
<andres.a.testi <at> gmail.com> wrote:

> Hello:
> Is it possible to instantiate scala objects in a declarative way like
> JSON. I think this would be a solution:
>
> val p = new Person{
>    name = "Peter"
>    age = 20
>    friends = Array(
>       new Person{
>           name = "Gary"
>       }
>    )
>
> }
>
> But I don't like to create a subclass of Person for a single instance.


Gmane