Is there a way to use “type” word as a variable name in Scala?

Spread the love

Question Description

It is frequent in my practice that a variable/argument is to store a type of something (as an enumeration value usually). And it usually makes no sense to specify an entity class in the name (like userType when a function is onlu intended to handle users). Is there a way I can use the “type” word for my needs instead of using scaffolds like “tipe”, “kind”, “somethingType” instead of it? The actual Scala type keyword is of such a rare use – it would be nice If I could undefine it (as a keyword) in the most of my code files.

Practice As Follows

You can escape with backticks:

val `type` = 5

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.