From: Dominik Honnef Date: 2010-04-25T09:01:30+09:00 Subject: Re: Defining your own typecaster On [Sun, 25.04.2010 08:37], Josh Cheek wrote: > Hi, how do you define your own typecaster? > > Builtin examples > > Array(1..5) # => [1, 2, 3, 4, 5] > Integer(5.2) # => 5 > Float(5) # => 5.0 > > > I would expect it to be something like this > > class Foo > def self.()(*objs) > Foo.new > end > end > > Foo(1) > > > But that isn't valid syntax, and I'm not sure what to look up to figure this > out. They're actually just methods with an uppercase name. class Foo … end def Foo(arg) Foo.new(…) end Foo(…) # => #