A
A
Alexander Korolev2015-12-12 18:15:56
ruby
Alexander Korolev, 2015-12-12 18:15:56

What is the best way to define const enums in ruby?

Good afternoon.
Periodically, the task arises in the class to have some constant enumeration, such as:

KINDS = {
    'clinic' => 1,
    'shop' => 2
  }

What is the best way to do this?
Initially, not everything was written:
in what form should the field that has the value of this enumeration be stored: text or number?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2015-12-12
@AMar4enko

{
  clinic: 1,
  shop: 2
}.freeze

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question