in reply to Re^3: Ternary operators: a hinderance, not a help
in thread Ternary operators: a hinderance, not a help

As an aside: in Ruby where if is an expression not a statement you can write something very close without all the extraneous squiggles.

number = if logical_test value else 0 end

Not to mention case is also an expression and can be used similarly.

zerg = case foo when "bar" Hydralisk.new when "baz" more_creep() else raise "Too few Starcraft references" end

--
We're looking for people in ATL

Replies are listed 'Best First'.
Re^5: Ternary operators: a hinderance, not a help
by Anonymous Monk on Aug 10, 2005 at 10:11 UTC
    That isn't exactly new. In ALGOL 68 (and perhaps earlier versions as well), you could do:
    IF a THEN b ELSE c FI := IF d THEN e ELSE f FI
    more or less equivalent to Perls:
    ($a ? $b : $c) = ($d ? $e : $f);
Re^5: Ternary operators: a hinderance, not a help
by Joost (Canon) on Aug 09, 2005 at 22:03 UTC
    Yes. Isn't Ruby nice ;-) Most of your example niceness is due to syntax, though... I've been using ruby for a couple of months now, and at first I didn't like the begin ... end type statements, but you get used to them pretty quicky, and now I actually prefer them over { ... } in ruby.

    Seriously, I'm using ruby for a project now, and it *is* pretty damn good. Some of the design decisions in perl 6 are good too, but overall, I actually like the current ruby design better than perl 6. I mean, hyper operators are cool and all, but where is my easy operator overloading?

    please someone tell me how to do overloading in perl 6