Proposal: Strings in Switch

Author

Joe Darcy

Date of Original Proposal

February 27, 2009

Text of Proposal

embedded in original proposal (mail)

Summary

Add the ability to switch on string values analogous to the existing ability to switch on values of the primitive types.

Relevant Mail Discussion Threads

Discussion

There were no replies to the original proposal on the PC mailing list.

There were some comments, but not significant discussion, when Joe posted a blog entry detailing the proposal. Of the comments, I would highlight the following

  • support case-insensitive switch: another commenter pointed out this is would require Locale-specific matching, which would complicate the proposal and implementation
  • null handling: several commenters requested that a special "case null" be supported. In the current proposal, switching on a null value will cause a NullPointerException to be thrown.
  • No labels