Closed steowens closed 8 years ago
Did you try type narrowing? In your example ...
if( is Float f = val, is Float f2 = other.val ) {
return f <=> f2;
}
Hi, @steowens, the syntax other.val is Float
does not perform type narrowing, it is just a plain expression of type Boolean
. What you would need is an is
condition, as shown above by @thradec.
Also the syntax (Float) other.val
is simply not legal Ceylon. That is a Java/C typecast, which does not exist in Ceylon.
You can find more information about this syntax here, here, and here.
I'm closing this issue since it's not a bug in Ceylon.
Thank you. Just saw your question and response. I am unfamiliar with Ceylon and was evaluating the language. Had the issue type been available I would have selected (question) as the issue type. Do you have a publicly accessible forum which we could use to ask such questions?
@steowens you can try both:
I believe those are enough to start.. but theres also dev chat and forum
Thank you. I didn't see those mentioned in your README.md file, nor on your Wiki. It might be a nice bit of info to include in your github site. I am sure I am not the only person who will be interested in learning where to go to ask questions.
So far I can find no way to build a compare function which accepts a class which has a value of type (Float? | Integer?).
For example:
Even though the above code tests the type of val and other.val and asserts them to be the same, it is impossible ot cast or compare the two values.