From: Michael Garriss Date: 2003-09-12T08:03:29+09:00 Subject: Re: Passing an Object Class from a method to a caller dblack@superlink.net wrote: >Hi -- > >On Fri, 12 Sep 2003, Michael Garriss wrote: > > > >>RLMuller wrote: >> >> >> >>>Hi All, >>> >>>I can't seem to pass an Object Class from a method to a calling routine >>> >>>Here's what I wrote: >>> >>>def getTypeOf(o) >>> aTypes = [Array, String, Numeric, Fixnum, Struct, MatchData] >>> result = Object >>> i = 0 >>> for t in aTypes >>> i += 1 >>> if o.is_a?t then >>> result=t >>> print "Index = #{i.to_s}: Type = '#{t.to_s}'\n" >>> break >>> end >>> result >>> end >>>end >>> >>> >>Looks like your 'break' is passing the 'result' line and thus returning >>the result of 'print'. >> >> > >I think it's actually returning the result of break, which is nil >(but can be assigned with "break val" in 1.8.0). > > > def this break "cool" while true end --> nil this --> "cool" I can't remember the last day I went without learning something cool about Ruby. Michael