Hi,
a = 3
#A
case a
when Fixnum
p "Fixnum"
end
#B
case a.class
when Fixnum
p "Fixnum"
end
why ist #A working while #B isn't?
Thanks!
Eric.
Hi,
a = 3
#A
case a
when Fixnum
p "Fixnum"
end
#B
case a.class
when Fixnum
p "Fixnum"
end
why ist #A working while #B isn't?
Thanks!
Eric.
% ri "Module.==="
------------------------------------------------------------- Module#===
mod === obj => true or false
On Thu, 29 Jul 2004 22:01:53 +0900, E.-R. Bruecklmeier <unet01@radio-eriwan.de> wrote:
Hi,
a = 3
#A
case a
when Fixnum
p "Fixnum"
end#B
case a.class
when Fixnum
p "Fixnum"
endwhy ist #A working while #B isn't?
------------------------------------------------------------------------
Case Equality---Returns +true+ if _anObject_ is an instance of
_mod_ or one of _mod_'s descendents. Of limited use for modules,
but can be used in +case+ statements to classify objects by class.
Thus:
case a.class
when Fixnum
p "Fixnum" # => Never Reached
when Class
p "Class!" # => or Object, or Module, or several others, see
a.class.ancestors
end
-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca
Because #A and #B are not the same!
Gavin
On Thursday, July 29, 2004, 11:01:53 PM, E.-R. wrote:
Hi,
a = 3
#A
case a
when Fixnum
p "Fixnum"
end
#B
case a.class
when Fixnum
p "Fixnum"
end
why ist #A working while #B isn't?
Austin Ziegler schrieb:
% ri "Module.==="
------------------------------------------------------------- Module#===
mod === obj => true or false
------------------------------------------------------------------------
Case Equality---Returns +true+ if _anObject_ is an instance of
_mod_ or one of _mod_'s descendents. Of limited use for modules,
but can be used in +case+ statements to classify objects by class.
Thanks a lot!
Eric.