1.1.1 filter方法函數
scala>val m = "hello world ".filter(_!=l)測試
m : String = heo wordspa
注:filter 方法將字符串中的等於l的字符串均過濾掉。scala
1.1.2 測試字符串的相等性排序
scala>val s1 = "hello"字符串
scala>val s2 = "HELLO"方法
scala>s1 == s2filter
res0:Boolean = falseword
scala>s1.toUpperCase == s2.toUpperCaseco
res1:Boolean = true
scala>s1.equalsIgnoreCase(s2)
res2:Boolean = true
注:toUpperCase函數將字符串所有轉換爲大寫進行排序。
equalsIgnoreCase函數忽略在字符串對比時的大小寫差別。