[fxruby-users] Support for Ruby 1.9?

Kevin Burge kevin.burge at systemware.com
Wed Apr 18 09:42:38 EDT 2007


(built this morning from trunk)

===
String.each

% ruby -v
ruby 1.9.0 (2007-04-18 patchlevel 0) [i686-linux]
% ruby -e '"a\nb\n".each { |l| puts l }'
-e:1:in `<main>': undefined method `each' for "a\nb\n":String 
(NoMethodError)

each_byte works though.
===
arity:

class A
  def self.meth_with_block(a, &block)
    puts block.arity
  end
end

A.meth_with_block do |arg1|
end

Ruby 1.9 => -2
Ruby 1.8.6 => 1

(I don't know if this is a bug in 1.9 or not.  I don't understand the 
logic behind -2 - you'd think it'd be 1).  From what I've seen on the 
mailing lists, -2 should be |a,*b|.

===
 From activesupport:

        def self.included(klass) #:nodoc:
          klass.funcall(:alias_method, :to_default_s, :to_s)
          klass.funcall(:alias_method, :to_s, :to_formatted_s)
        end

works, but:

        def self.included(klass) #:nodoc:
          klass.send(:alias_method, :to_default_s, :to_s)
          klass.send(:alias_method, :to_s, :to_formatted_s)
        end

doesn't.
===
about "when" clause, a couple libraries I use do this:

case somevar
when 1: true
when 2: false
end

This no longer works in 1.9.  You have to do:

when 1; true
when 2; false

or

when 1 then true
when 2 then false

I've never done this in my own code.

===
You are correct about RB_STRING* also, it is RSTRING*, just misspoke.  
My quick hack was to replace all with the _PTR and _LEN macros.  I'll 
update my own libraries to use StringValuePtr and StringValueCStr.  Thanks!


Kevin


http://www.systemware.com/



More information about the fxruby-users mailing list