22 Dec 22:55
Re: Scala Object Notation ( SCON? )
Tony Morris <tmorris <at> tmorris.net>
2007-12-22 21:55:12 GMT
2007-12-22 21:55:12 GMT
Rickard Nilsson wrote:
> 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
The Haskell-record syntax (or similar) would be great! In the meantime,
I have been writing a function for each field. For your example, I would
write name: Person -> String -> Person
--
Tony Morris
http://tmorris.net/
Hey! We had 40,000 lines of C# here yesterday, but now there are 40
lines of... Dear God, what is a catamorphism?"
RSS Feed