Core

self

The current object.

Example:

> 1 instance-eval: self
1
> "hello" instance-eval: self
"hello"
true

The value representing truth and virtue.

Example:

> 2 + 2 == 4
true
false

The value representing falsity and vice.

false and nil are the only two values considered non-true.

Example:

> 2 + 2 == 5
false
nil

The value representing the absense of value.

false and nil are the only two values considered non-true.

Example:

> [1, 2, 3][4]
nil
undefined

Perhaps a peculiar constant coming from Ruby, representing the true absense of value. For example, this is used to specify that an argument should be considered unspecified, and cause it to inherit its default value if there is one.

Example:

> foo(a = 1, b = 2) := [a, b]
#<Rubinius::CompiledMethod foo file=wrapper>
> foo(undefined, 3)
[1, 3]

It is also used for unspecified values in a Particle.

Example:

> .foo(1, _) arguments
[1, undefined]
~receiver ~(message ? to-word)

A basic message send.

Example:

> 1 inspect
"1"
> "foo" nil?
false
~receiver (~(message ? to-word))(~*arguments)

A basic message send with arguments.

Example:

> "fii" gsub("i", "o")
"foo"
macro(~pattern): ~*body

A macro for defining macros. Defines in the current module.

Example:

> macro(2 + 2): 5
#<Rubinius::CompiledMethod _expand_+ file=wrapper>
> 2 + 2
5
[~*args]: ~*body

A block with arguments.

Example:

> [x]: x + 1
#<Proc:0x4ed3c@interaction:1>
[~*args] &~block: ~*body

A block with arguments and a proc-arg.

Example:

> [x] &y: y call(x)
#<Proc:0x4f1b8@interaction:1>
&~block: ~*body

A block with a proc-arg.

Example:

> &y: y call(42)
#<Proc:0x4f554@interaction:1>
~(message ? to-word): ~*body

A private message send with a proc-arg.

Example:

> tap: 1
#<Atomy::Module ''>
> tap { 1 }
#<Atomy::Module ''>
(~(message ? to-word))(~*args): ~*body

A private message send with arguments and a proc-arg.

Example:

> foo(_) &baz := baz call
#<Rubinius::CompiledMethod foo file=wrapper>
> foo(41): puts("called")
called
"called"
(~(message ? to-word))(~*args) [~*block-args]: ~*body

A private message send with arguments and a proc-arg with arguments.

Example:

> foo(bar) &baz := baz call(bar)
#<Rubinius::CompiledMethod foo file=wrapper>
> foo(41) [x]: puts("called with " + x inspect)
called with 41
"called with 41"
~receiver ~(message ? to-word): ~*body)

A message send with a proc-arg to receiver.

Example:

> 1 tap: puts("xyz")
xyz
1
~receiver ~(message ? to-word) [~*block-args]: ~*body)

A message send to receiver with a proc-arg with arguments.

Example:

> [1, 2, 3] collect [x]: x + 1
[2, 3, 4]
~receiver (~(message ? to-word))(~*args): ~*body)

A message send to receiver with arguments and a proc-arg.

Example:

> [0, 2] zip([1, 3]): puts("xyz")
xyz
xyz
nil
~receiver (~(message ? to-word))(~*args) [~*block-args]: ~*body)

A message send to receiver with arguments and a proc-arg with arguments.

Example:

> [1, 2, 3] inject(0) [x, y]: x + y
6