<URL:> などから。


Ruby2 と Rite の違い

Ruby2 は言語仕様。 Rite はその実装。

Path to Ruby2

After releasing 1.8.1 (hoped to be soon), 1.9.x will be started.

1.8.1 をリリースしたら 1.9 ブランチをスタートする。

How Ruby2 would be

New Local Variable Scope

Instance Variables

Instance variables can be local to the class/module when explicitly specified, or by default.

@foo = 42    # can be accessed from subclasses
@_foo = 55   # local to the class/module

Or other way around.

New Constant Look-up

Constant Look-up Problem

The priority

The possible new constant look-up rules:

New Class Variables

The new class variable look-up rules:

If you need to access class variables from outside, define accessors.

Statement and Expression Revisited

print 1 or 2
print(1 or 2)
print(1 or 2, "\n")

"foo" "bar"

 + another_long_expression)

(a; b)          # error
begin a; b; end # instead of above

abc → a, def → b にしました。これってエラーになります?

Multiple Values

Source of Confusion

a, b, c = x


x = [1,2,3]

should they be





This happens on both multiple assignment, block parameter assignment.

This problem will be solved either

See also Ruby2.0BlockParameterAndMultipleValueAssignment

Both have their drawback, but better than the current behavior.

Method Visibilities

public/private separation

private may be in the saparate name space from public/protected. maybe, just an idea.

Range in Condition

print line if f.lineno == 1 .. f.lineno == 2

Can you remember its behavior? I don't.

.. behave like AWK ... behave like SED


Should be either removed or changed. Ideas wanted.

Keyword Argument

def foo(a, b: 42, **keys)
   p [a,b,keys]
foo(1)             # => [1,42,{}]
foo(2, b: 5)       # => [2,5,{}]
foo(3, b: 4, c: 6) # => [3,4,{:c=>6}]

New Hash Literal

{a: 45, b: 55, c: 65}

as another form of:

{:a => 45, :b => 55, :c => 65}

Method Combination

Hooks can be added to arbitrary method

class Foo
   def foo:pre(*args)
     p "pre"
   def foo:post(*args)
     p "post"
   def foo:wrap(*args)
     p "wrap pre"
     p "wrap post"
   def foo(*args)
     p "foo"

wrap pre
wrap post

Selector Namespace

You can add methods to existing class globally now. But global changes are evil.

Selector namespace is a feature to encapsulate changes in certain scope.

$a = "4"
namespace foo # syntax may change
  class String
    def to_i
  p $a.to_i   # => 0, in this namespace
end # of namespace
p $a.to_i     # => 4

namespace の名前ってどう使うんだろう。ns_name.namespace_eval{ ... } とかかな。namespace もオブジェクトになるのかな。

Optional Type

We already have StrongTyping and types.rb, but...

No concrete idea, yet.


lambda with local variable

Method Search Rule

Proc literal


Proc オブジェクトをリテラルとして作ることができる。

x = {|a| p a};        #=> 4 を表示
x = (do |a| p a end); #=> 9 を表示
x = {|| p 1};                   #=> 1 を表示
x = (do p 1 end);        #=> 1 を表示

注意:このリテラル表記はRuby2.0BlockParameterNotationの"->"による表記を導入する際に取り止めとなったそうです。 ( 参考: <URL:> )

Block parameter notation

The RWiki