Created
April 4, 2018 11:33
-
-
Save YordanGeorgiev/d97875885753b93245f015ab73214949 to your computer and use it in GitHub Desktop.
[fall-trough-random-cases] how-to fall trough random cases with match in scala #scala #match #case #fall-trough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pick randomly a file type to generate a valid dataframe for | |
val random = math.random | |
val randomType : RandomType = { | |
random match { | |
case a if (random >= 0 && random < 0.33) => { | |
RandomType.Type1 | |
} | |
case b if (random >= 0.33 && random < 0.66) => { | |
RandomType.Type2 | |
} | |
case _ => { | |
RandomType.Type3 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment