From: Florian Gilcher Date: 2007-11-12T23:04:01+09:00 Subject: Re: does Ruby has method properties Actually, this cannot work in Ruby. In Java, the return type of a method is defined, in ruby, a method has no return type. Consider this: def string_or_double(type) if type == :string return "String" else return 0.01 end end So this method can have the return type String or Double. Ruby doesn't care, so it doesn't have and can't even find out which type is returned without executing the method. Java, on the other hand, does care - it would only accept such a construct if I defined the method to return a generic Object. On Nov 12, 2007, at 11:09 AM, Ryan Davis wrote: > > On Nov 12, 2007, at 00:35 , Thilina Buddhika wrote: > >> In java script it is possible to something like this, >> method.outputType = "string"; >> >> we are setting the return type of the method. Is this possible in >> Ruby? >> >> i searched in the google and found this. >> >> http://bias2build.com/thesis/ruby_v_js_MP.html >> >> it says that this is not possible in Ruby. >> >> i wanna confirm this. > > Confirmed. There is virtually no metadata about a method available > to the public. Arity is about the only one I can think of. > >