http://techblog.realestate.com.au/the-abject-failure-of-weak-typing/
I'm wondering if a useful feature is missing from Ceylon.
In particular, I'm referring to that of simple wrapper/case classes that implement semantics for hashcode/equals/tostring.
For example, if I want a simple class for an email String:
class Email(shared String emailStr) { /* possible validation code in initializer */}
I would need to implement my own hashcode/equals/string attributes/methods, especially if I want to use them as part of a collection, would I not? Then again, I suppose there are inherent risks to the compiler generating such code, even on a limited basis?
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/a6a7985b-c037-4512-9801-7b0032cab2ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In particular, I'm referring to that of simple wrapper/case classes that implement semantics for hashcode/equals/tostring.For example, if I want a simple class for an email String:
class Email(shared String emailStr) { /* possible validation code in initializer */}
I would need to implement my own hashcode/equals/string attributes/methods, especially if I want to use them as part of a collection, would I not? Then again, I suppose there are inherent risks to the compiler generating such code, even on a limited basis?
Guava offers functions for easy / correct implementation of hashCode, equals and toString (in Java):