DEV Community

suLeeTate
suLeeTate

Posted on

Lesson19Stuff

Lesson 19 Discussion

Please create a blog on dev.to with the following information:

1.Explain in your own words the lesson.

2.Include the following questions:
Why should you consider using an enum over using a String or an Int to identify options?

Today’s lesson was Enumerations and Switches. How to use them and how to shorten code or using a shortcut for conditionals. An enumeration defines a common type for a group of related values. It lets you manipulate the values safely within the code. The values in an Enum are called cases and called with the “case” keyword. You can also match values in an Enum with a Switch statement. Switch statements can replace conditionals and allows for faster and less typing.

You should use enums instead of strings or Ints to identify values that are related. This allows you to manipulate the values with less code and prevents coders from having to write a conditional statement for each value.

Top comments (0)