From: Trans Date: 2005-11-04T12:27:09+09:00 Subject: Some comments on new 1.9 features Just looking at http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9. Nicely done! Comment on a couple things 1) ;; instead of end It is possible to use ;; instead of end. (1..100).inject do |s,x| s+x ;; # => 5050 class Foo def foo; "foo" end ;; Foo.new.foo # => "foo" What's the rationle here? I'd rather have a punctutation mark for 'do' (yes, ':' again ;-p) (1..100).inject: |s,x| s+x end # => 5050 Of course could have both: (1..100).inject: |s,x| s+x ;; # => 5050 2) Block local variables Used as follows: # {normal args; local variables} d = 2 a = lambda{|;d| d = 1} a.call() d # => 2 When a variable is shadowed, ruby1.9 issues a warning: -:2: warning: shadowing outer local variable - d Come on. This stinkos. At some point I think you have to give it up and allow a declaration. 3) Calling Procs without #call/#[] You can now do: a = lambda{|*b| b} (a)(1,2) # => [1, 2] Note that you need the parentheses: a = lambda{|*b| b} a(1,2) # => ERROR: (eval):2: compile error... I know this has been deprecated, but what causes this not to work exactly? 4) send doesn't call private methods anymore ruby-talk:153672 It is still possible to call them with the newly introduced #funcall method. class Foo; private; def foo; end; end Foo.new.funcall(:foo) # => nil Foo.new.send(:foo) # => ERROR: private method `foo' called for # No #funcall please, I already have enough methods to make exceptions for in BlankSlate/BasicObject. Use #instance_send instead. Thank you. 5) Class of singleton classes singleton class inherits Class rather than its object's class class X;end; x=X.new; class << x; self < X; end # => true vs. (1.8) class X;end; x=X.new; class << x; self < X; end # => nil Is this example backwards? I'm confused. Please confirm. 6) Class variables are not inherited ruby-dev:23808 class A; @@a = 1; end; class B < A; @@a end # => ERROR: (eval):1: uninitialized ... vs. class A; @@a = 1; end; class B < A; @@a end # => 1 Love it! Thank you! T.