Skip to content

Instantly share code, notes, and snippets.

@YordanGeorgiev
Created April 4, 2018 11:33
Show Gist options
  • Save YordanGeorgiev/d97875885753b93245f015ab73214949 to your computer and use it in GitHub Desktop.
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
// 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