Re: Why can't switch be used for objects
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 24 Jun 2005 19:27:46 +0100
Bruce Wood <brucewood@xxxxxxxxxx> wrote:
> 1. Because it would be grossly slow.
> 2. Because the semantics of comparison are unclear (do you use equality
> by reference, or use the Equals method, or do you allow IComparers,
> or... ?)
> 3. Because if you need this then there is probably some other (cleaner)
> way to do what you want to do... which is why I'm wondering exactly
> where you need this switch statement and for what, in order to propose
> an alternate design. :-)
Actually, it's not entirely unreasonable, nor does it need to be slow -
with some extra support.
I've recently been playing around with Java 1.5's enums, which allow
switching and all kinds of fun. They're much more powerful than the
..NET enums - although there are certain bits of behaviour from .NET's
"simple" enums which Java makes slightly harder.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
- References:
- Why can't switch be used for objects
- From: cody
- Re: Why can't switch be used for objects
- From: Bruce Wood
- Re: Why can't switch be used for objects
- From: cody
- Re: Why can't switch be used for objects
- From: Bruce Wood
- Why can't switch be used for objects
- Prev by Date: Re: Printing PDF from C# on-the-fly?
- Next by Date: Re: Can i access from c# to java via JNI ?
- Previous by thread: Re: Why can't switch be used for objects
- Next by thread: Re: Why can't switch be used for objects
- Index(es):
Relevant Pages
|