Skip to content

Latest commit

 

History

History
50 lines (29 loc) · 897 Bytes

NOTES.md

File metadata and controls

50 lines (29 loc) · 897 Bytes

Notes

Todos

  • allow / add support equal == by integer or symbol - why? why not? e.g.
color == :red    #=> ???
color == 0       #=> ???

or always use color == Color.red ???

Enums in Ruby

No library needed, just use symbols :-) e.g.

Color = [:red, :blue, :green]
Color[0]  #=> :red
Color[1]  #=> :blue

# -or-
Color = {red: 0, blue: 1, green: 2}
Color[:red]   #=> 0
Color[:blue]  #=> 1

Weekday = [:mon, :tue, :wed, :thu, :fri, :sat, :sun]
Weekday[0]  #=> :mon

Why? Why not? Discuss.

Search Rubygems https://rubygems.org/search?query=enum

Enums in Crystal

Enums in Python

Robust enumerated type support in Python - RETIRED, see (new) enum Data Type in Standard Library https://pypi.org/project/enum

The Python Standard Library - enum Data Type - Support for Enumeration in Python 3+ https://docs.python.org/3/library/enum