R
RLMuller
This is a multi-part message in MIME format.
------=_NextPart_000_004C_01C37882.24993D90
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
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 =3D [Array, String, Numeric, Fixnum, Struct, MatchData]
result =3D Object
i =3D 0
for t in aTypes
i +=3D 1
if o.is_a?t then=20
result=3Dt
print "Index =3D #{i.to_s}: Type =3D '#{t.to_s}'\n"
break
end
result
end
end
obj =3D "abc"
print "Type of object '#{obj.to_s}' is '#{getTypeOf(obj).to_s}'\n\n}"
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Here's what I get when running under SciTE:
ndex =3D 2: Type =3D 'String'
Type of object 'abc' is ''
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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)
------=_NextPart_000_004C_01C37882.24993D90
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi All,</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I can't seem to pass an Object Class from a method =
to a=20
calling routine</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Here's what I wrote:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>def =
getTypeOf(o)<BR> =20
aTypes =3D [Array, String, Numeric, Fixnum, Struct,=20
MatchData]<BR> result =3D=20
Object<BR> i =3D=20
0<BR> for t in=20
aTypes<BR> &nb=
sp; i=20
+=3D =
1<BR> =
if=20
o.is_a?t then=20
<BR> &nb=
sp; =20
result=3Dt<BR>  =
; =20
print "Index =3D #{i.to_s}: Type =3D=20
'#{t.to_s}'\n"<BR> &=
nbsp; =20
break<BR> &nbs=
p;=20
end<BR> =20
result<BR> =
end<BR>end</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>obj =3D "abc"<BR>print "Type of object '#{obj.to_s}' =
is=20
'#{getTypeOf(obj).to_s}'\n\n}"<BR></FONT></DIV>
<DIV><FONT =
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Here's what I get when running under =
SciTE:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>ndex =3D 2: Type =3D 'String'<BR>Type of object =
'abc' is=20
''<BR></FONT></DIV>
<DIV><FONT =
size=3D2> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I originally tried to place the .to_s after "result" =
in the=20
subroutine, instead of after the invocation of getTypeOf, to no=20
avail.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Any ideas?</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>TIA,</FONT></DIV>
<DIV><FONT size=3D2>Regards,<BR>Richard</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>A programmer is a device for turning coffee into =
code.<BR>Jeff=20
Prosise (with an assist from Paul Erdos)<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_004C_01C37882.24993D90--
------=_NextPart_000_004C_01C37882.24993D90
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
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 =3D [Array, String, Numeric, Fixnum, Struct, MatchData]
result =3D Object
i =3D 0
for t in aTypes
i +=3D 1
if o.is_a?t then=20
result=3Dt
print "Index =3D #{i.to_s}: Type =3D '#{t.to_s}'\n"
break
end
result
end
end
obj =3D "abc"
print "Type of object '#{obj.to_s}' is '#{getTypeOf(obj).to_s}'\n\n}"
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Here's what I get when running under SciTE:
ndex =3D 2: Type =3D 'String'
Type of object 'abc' is ''
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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)
------=_NextPart_000_004C_01C37882.24993D90
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1226" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi All,</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I can't seem to pass an Object Class from a method =
to a=20
calling routine</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Here's what I wrote:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>def =
getTypeOf(o)<BR> =20
aTypes =3D [Array, String, Numeric, Fixnum, Struct,=20
MatchData]<BR> result =3D=20
Object<BR> i =3D=20
0<BR> for t in=20
aTypes<BR> &nb=
sp; i=20
+=3D =
1<BR> =
if=20
o.is_a?t then=20
<BR> &nb=
sp; =20
result=3Dt<BR>  =
; =20
print "Index =3D #{i.to_s}: Type =3D=20
'#{t.to_s}'\n"<BR> &=
nbsp; =20
break<BR> &nbs=
p;=20
end<BR> =20
result<BR> =
end<BR>end</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>obj =3D "abc"<BR>print "Type of object '#{obj.to_s}' =
is=20
'#{getTypeOf(obj).to_s}'\n\n}"<BR></FONT></DIV>
<DIV><FONT =
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Here's what I get when running under =
SciTE:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>ndex =3D 2: Type =3D 'String'<BR>Type of object =
'abc' is=20
''<BR></FONT></DIV>
<DIV><FONT =
size=3D2> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I originally tried to place the .to_s after "result" =
in the=20
subroutine, instead of after the invocation of getTypeOf, to no=20
avail.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Any ideas?</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>TIA,</FONT></DIV>
<DIV><FONT size=3D2>Regards,<BR>Richard</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>A programmer is a device for turning coffee into =
code.<BR>Jeff=20
Prosise (with an assist from Paul Erdos)<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_004C_01C37882.24993D90--