Your Ad Here

Tag Archive for 'io'

Conditionals in Io

Was playing a little with Io. I like one of the options for the conditional if; you can basically just pass “if” three arguments; a statement, something to do if it’s true, and something to do if it’s false.

So you can do simply:


Io> a := 3
==> 3
Io> if(a%2==0, writeln("a is even"), writeln("a is odd"))
a is odd
==> nil

I know, in ruby you could just do a%2==0?"a is even":"a is odd", and similar in other languages. I do like the idea of if looking like a function to which I’m passing arguments, though. Just seems intuitive, somehow.