Getting Started with Io
map
Io> list(10, 11, 12, 13, 14, 15) map(asHex) ==> list(0a, 0b, 0c, 0d, 0e, 0f)
Regex with capturing
Io> "<code:io>" matchesOfRegex("<code:([a-z]+)>") at(0) captures ==> list(<code:io>, io)
Runing an external process
Io> rc := System runCommand ("ls") Io> rc slotNames ==> list(exitStatus, succeeded, stdout, successStatus, failed, stderr)
Async message
Io> long_method := method( ... System sleep(5) ... "done" ... ) ==> method( System sleep(5) "done" ) Io> foo := @long_method; nil ==> nil Io> foo ==> done done
Boolean Expressions
x := 5 y := 9 if((x == 3) or (y == 9), true, false)
Constructors
MyObj := Object clone do( newSlot("deg") with := method(rad, self clone setDeg(rad * 180 / Number constants pi)) ) my := MyObj with(0.5) my deg # 28.6478897565411614
Hello world Unit Test
StringTest := UnitTest clone do( testInterpolate := method( count := 3 item := "ball" assertEquals( "#{count} #{item}s" interpolate, "3 balls" ) ) if(isLaunchScript, verbose := getSlot("writeln") run ) ) FileCollector run