文档介绍:Reinventing the wheel ? When you learn a foreign language, you learn both the grammar (syntax) and the vocabulary ? If you learn just a few hundred words, you can usually make yourself understood (though you may not understand other people), but that doesn ’ t make you fluent in the language ? If you were writing in the foreign language, you would use a dictionary to express yourself better ? When you learn a programming language, you learn both the syntax and the libraries ( “ vocabulary ”) ? You can write (almost) any program using only the syntax ? if (me == "Tarzan") you = "Jane" ? You are not “ speaking ” Scala, you are writing it ? Learn to use the libraries! 1 Converting to lowercase ? scala> :paste // Entering paste mode (ctrl-D to finish) val s = "Letters AND digits, 1 2 3!" var lc = "" for (ch <- s) { if (ch >= 'A' && ch <= 'Z') { lc = lc + (ch - 'A' + 'a').toChar } else { lc = lc + ch } } (Entered ctrl-D) // Exiting paste mode, now interpreting. s: String = Letters AND digits, 1 2 3! lc: String = letters and digits, 1 2 3! ? scala> val lc2 = lc2: String = letters and digits, 1 2 3! 2 Discovering methods in the REPL ? In the REPL, you can hit a tab after a period to find out what methods are available ? scala> "abc". TAB + asInstanceOf charAt codePointAt codePointBefore codePointCount compareTo compareToIgnoreCase concat contains contentEquals endsWith equalsIgnoreCase getBytes getChars indexOf intern isEmpty isInstanceOf lastIndexOf length matches offsetByCodePoints regionMatches replace replaceAll replaceFirst split startsWith subSequence substring toCharArray