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
obj = "abc"
print “Type of object ‘#{obj.to_s}’ is ‘#{getTypeOf(obj).to_s}’\n\n}”
···
========================================
Here’s what I get when running under SciTE:
ndex = 2: Type = 'String’
Type of object ‘abc’ is ‘’
===================================
I originally tried to place the .to_s after “result” in the subroutine, instead of after the invocation of getTypeOf, to no avail.
Any ideas?
TIA,
Regards,
Richard
A programmer is a device for turning coffee into code.
Jeff Prosise (with an assist from Paul Erdos)