Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 787
Ivan Avatar asked Nov 20 '11 01:11

Ivan


1 Answers

You can escape with backticks:

val `type` = 5
like image 175
Owen Avatar answered Sep 30 '22 01:09

Owen