Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby array of US state name and abbreviations
states = Array[ ["AK", "Alaska"],
["AL", "Alabama"],
["AR", "Arkansas"],
["AS", "American Samoa"],
["AZ", "Arizona"],
["CA", "California"],
["CO", "Colorado"],
["CT", "Connecticut"],
["DC", "District of Columbia"],
["DE", "Delaware"],
["FL", "Florida"],
["GA", "Georgia"],
["GU", "Guam"],
["HI", "Hawaii"],
["IA", "Iowa"],
["ID", "Idaho"],
["IL", "Illinois"],
["IN", "Indiana"],
["KS", "Kansas"],
["KY", "Kentucky"],
["LA", "Louisiana"],
["MA", "Massachusetts"],
["MD", "Maryland"],
["ME", "Maine"],
["MI", "Michigan"],
["MN", "Minnesota"],
["MO", "Missouri"],
["MS", "Mississippi"],
["MT", "Montana"],
["NC", "North Carolina"],
["ND", "North Dakota"],
["NE", "Nebraska"],
["NH", "New Hampshire"],
["NJ", "New Jersey"],
["NM", "New Mexico"],
["NV", "Nevada"],
["NY", "New York"],
["OH", "Ohio"],
["OK", "Oklahoma"],
["OR", "Oregon"],
["PA", "Pennsylvania"],
["PR", "Puerto Rico"],
["RI", "Rhode Island"],
["SC", "South Carolina"],
["SD", "South Dakota"],
["TN", "Tennessee"],
["TX", "Texas"],
["UT", "Utah"],
["VA", "Virginia"],
["VI", "Virgin Islands"],
["VT", "Vermont"],
["WA", "Washington"],
["WI", "Wisconsin"],
["WV", "West Virginia"],
["WY", "Wyoming"] ]
Copy link

ghost commented Jul 18, 2012

Braces missing for Ohio and Illinois and Wyoming isn't spelled out.

edit: It's fixed. Handy stuff to find. Thanks.

@dblandin
Copy link
Author

dblandin commented Jul 18, 2012

Right! Thanks for reminding me to update this!

@rdetert
Copy link

rdetert commented May 3, 2014

@icem
Copy link

icem commented Dec 3, 2015

take a look at carmen gem https://github.com/jim/carmen

@rdyson
Copy link

rdyson commented Mar 25, 2016

Thanks for this!

@saaage
Copy link

saaage commented Jun 13, 2017

Thanks!

@mailaw
Copy link

mailaw commented May 9, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment