On 18 September 2010 10:01, Kevin Wright <[email protected]> wrote:
>
>
> This is the same approach that Scala takes, but with Scala all the
> construction and copy logic is built in:
>
> case class Haha(firstName : String, lastName : String) {
> val name = firstName + " " + lastName
> }
>
>
>
I can actually go a bit further here:
trait Named {
def name : String // it's a def, so could be implemented by a
method...
}
case class Haha(firstName : String, lastName : String) extends Named {
val name = firstName + " " + lastName // ... but can also implemented
by a val
}
This is the essence of the uniform access principle.
--
Kevin Wright
mail / gtalk / msn : [email protected]
pulse / skype: kev.lee.wright
twitter: @thecoda
--
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.