Permalink
Browse files

More readme/markdown issues

  • Loading branch information...
1 parent 187a805 commit f1e2f084abea99d5e35253506844854faa2981d6 @sgibbons committed Jun 12, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 README.md
View
@@ -7,11 +7,16 @@ This project is an attempt to provide c-style enums for ruby. It's obviously imp
Symbols are great. You should probably keep on using symbols in most of the places that you currently do. There are, however, certain situations that enums are better suited for. For instance:
* A variable can take on a finite set of known, named, values.
- > The set of values that a variable can take on define that variable's type. Rather than just scattering symbols throughout your code that modifes the variable, it is frequently helpful to encapsulate the type information in one place. An enum, being a lightweight, in-line class definition, is an ideal place to do this. Examples of this type of situation would be when you need to represent days-of-the-week or drink sizes available
+
+ The set of values that a variable can take on define that variable's type. Rather than just scattering symbols throughout your code that modifes the variable, it is frequently helpful to encapsulate the type information in one place. An enum, being a lightweight, in-line class definition, is an ideal place to do this. Examples of this type of situation would be when you need to represent days-of-the-week or drink sizes available
+
DayOfWeek = enum :sun, :mon, :tues, :wed, :thurs, :fri, :sat
DrinkSize = enum :small, :medium, :large
+
* A dual name/value representation is needed. This is particularly common when you have a set of possible values with an inherent ordering.
- > Enums have the property of defining both names and values, so you can sometimes get the best of both worlds by using them.
+
+ Enums have the property of defining both names and values, so you can sometimes get the best of both worlds by using them.
+
DrinkSize = enum :small, :medium, :large
DrinkSize::SMALL < DrinkSize::LARGE # true

0 comments on commit f1e2f08

Please sign in to comment.