Re: TrueClass/FalseClass vs. Boolean
- From: Gregory Seidman <gsslist+ruby@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 1 Apr 2006 05:44:24 +0900
On Sat, Apr 01, 2006 at 12:38:43AM +0900, baumanj@xxxxxxxxx wrote:
} ara.t.howard@xxxxxxxx wrote:
} > On Fri, 31 Mar 2006, Christian Neukirchen wrote:
} > > if a.kind_of? Boolean
} > >
} > > case y
} > > when Integer
} > > when Boolean
} > > end
}
} What kind of scenarios would you want to use such a construct? It seems
} to me not very rubyish to be switching based on the class of an object.
} As I understand it, the more conventional way to deal with potentially
} diverse argument types is to use the respond_to? method. This keeps the
} door open for duck typing.
[...]
The most obvious answer is that it is needed for various kinds of
serialization. I wrote something like this just the other day. I needed to
do XML-RPC serialization (yes, I know there is XML-RPC support in the
standard library, but I needed something slightly different that was easier
to do by hand), so I needed to know what kind of value I was serializing.
--Greg
.
- References:
- TrueClass/FalseClass vs. Boolean
- From: PrimaryKey
- Re: TrueClass/FalseClass vs. Boolean
- From: baumanj@xxxxxxxxx
- Re: TrueClass/FalseClass vs. Boolean
- From: ara . t . howard
- Re: TrueClass/FalseClass vs. Boolean
- From: baumanj@xxxxxxxxx
- TrueClass/FalseClass vs. Boolean
- Prev by Date: Re: Best tools for compiling Ruby (Windows)?
- Next by Date: Trying to get stat, Win32API to work
- Previous by thread: Re: TrueClass/FalseClass vs. Boolean
- Next by thread: Re: TrueClass/FalseClass vs. Boolean
- Index(es):
Relevant Pages
|