Programming in Scala 3rd edition中的一個問題

第48頁的例子中scala

thrill.sort((s,t)=>

 | s.charAt(0).toLower <

 | t.charAt(0).toLower)

在Scala 2.12.3版本中運行會報錯,顯示code

error: value sort is not a member of List[String]it

查閱了Scala的API,應該使用sortWith方法class

thrill.sortWith((s,t)=>
     | s.charAt(0).toLower <
     | t.charAt(0).toLower)
相關文章
相關標籤/搜索