From: Daniel Schierbeck Date: 2006-05-28T18:04:22+09:00 Subject: Re: Crazy thought -- Rubyish type conversion? I even got an implementation, although it obviously differs a lot from the proposed syntax. class Module alias_method :__define_method__, :define_method def define_method(name, *types, &block) if types.length > 0 __define_method__(name) do |*args| args.each_index do |i| unless types[i].nil? args[i] = args[i].send("to_#{types[i]}") end end block.call(*args) end else __define_method__(name, &block) end end end class Test define_method(:foo, :sym, nil, :s) do |a, b, c| p a, b, c end end Test.new.foo("bar", 5, 6) #=> :bar, 5, "6" Cheers, Daniel