Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Io (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Examples === The ubiquitous [[Hello world program]]: <syntaxhighlight lang="io"> "Hello, world!" println </syntaxhighlight> New objects are created by [[Cloning (programming)|cloning]] objects. In Io specifically, a new, empty object is created and only the differences between it and its parent are stored within the new object; this behavior is known as [[differential inheritance]]. An example of this behavior is shown: <syntaxhighlight lang="io"> A := Object clone // creates a new, empty object named "A" </syntaxhighlight> A simple non-recursive factorial function, in Io: <syntaxhighlight lang="io"> factorial := method(n, if(n == 0, return 1) res := 1 Range 1 to(n) foreach(i, res = res * i) ) </syntaxhighlight> Because assignment of <code>res * i</code> to <code>res</code> is the last action taken, the function implicitly returns the result and so an explicit return expression is not needed. The above demonstrates the usage of [[Range (computer programming)|ranges]], and doesn't use a <code>for()</code> loop, which would be faster.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)