2009/8/15 Ken.Dickey <[email protected]>:
> Taking a hint from the comments (yes, I do listen), here is a "less
> complex" :) solution:
>
> Complex>>
> < aNumber
> "Not defined on Complex numbers"
>
> ^self asReal < aNumber asReal
>
> Complex>>
> asReal
> "Answer real-part of self if imaginary is zero else, error"
> (imaginary = 0)
> ifTrue: [^real]
> ifFalse: [self error: 'Can''t convert to real']
>
> Better?
By reading a comment: "Not defined on Complex numbers"
i wonder why implementation is different than following:
Complex>>
< aNumber
"Not defined on Complex numbers"
self shouldNotImplement
;)
But yes, given the fact that Complex numbers could be used by someone
in code as real numbers, and therefore expecting #< to work, an
implementation proposed by you is plausible.
>
> -KenD
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
--
Best regards,
Igor Stasenko AKA sig.
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project