Last active
December 20, 2015 21:09
-
-
Save lu911/6195820 to your computer and use it in GitHub Desktop.
seq method test
This file contains 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
object Main { | |
def main(args: Array[String]): Unit = { | |
new SeqMethods() | |
} | |
} | |
class SeqMethods { | |
private val digits = Seq(1,3,5,7) | |
private val chars = Seq("a", "b", "c", "d", "a", "c", "b") | |
println("digits : " + digits) | |
println("chars : " + chars) | |
val methods = List(contains, containsSlice, startsWith, endsWith, reverse, sorted, indexOf, lastIndexOf) | |
def contains(): Unit = { | |
println("-"*5 + " digits contains 1 " + "-"*5) | |
println(digits contains 1) | |
} | |
def containsSlice(): Unit = { | |
println("-"*5 + " digits containsSlice Seq(3,5) " + "-"*5) | |
println(digits containsSlice Seq(3,5)) | |
} | |
def startsWith(): Unit = { | |
println("-"*5 + " digits startsWith Seq(1,3) " + "-"*5) | |
println(digits startsWith Seq(1,3)) | |
} | |
def endsWith(): Unit = { | |
println("-"*5 + " digits endsWith Seq(5,7) " + "-"*5) | |
println(digits endsWith Seq(5,7)) | |
} | |
def reverse(): Unit = { | |
println("-"*5 + " digits reverse " + "-"*5) | |
println(digits reverse) | |
} | |
def sorted(): Unit = { | |
println("-"*5 + " chars sorted " + "-"*5) | |
println(chars sorted) | |
} | |
def indexOf(): Unit = { | |
println("-"*5 + " chars indexOf \"a\" " + "-"*5) | |
println(chars indexOf "a") | |
} | |
def lastIndexOf(): Unit = { | |
println("-"*5 + " chars lastIndexOf \"a\" " + "-"*5) | |
println(chars lastIndexOf "a") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment