Skip to content

Commit

Permalink
Try to clean up some formatting in the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sgibbons committed Jun 12, 2011
1 parent fcd146e commit 187a805
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -7,11 +7,11 @@ 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

Expand Down

0 comments on commit 187a805

Please sign in to comment.