Created
February 26, 2021 21:15
-
-
Save deanwampler/35ed4392fd7b84eeecaf904aafcc13ee to your computer and use it in GitHub Desktop.
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
import Matrix.`*` | |
def `1 + 1 == 2 test` = assert(1+1 == 2) // Readable test names! | |
def contains(i: Int, seq: Seq[Int]): Boolean = seq match { | |
case Nil => false | |
case `i` +: _ => true // Must use back ticks, or i is just a new variable that shadows the method argument. | |
case _ +: tail => contains(i, tail) | |
} | |
contains(3, Seq(1,2,3)) // true | |
contains(3, Seq(1,2)) // false | |
... | |
java.util.Scanner.`match` // Call a Java method named like a Scala reserved word. | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment