标签:
1. 在Scala REPL 中键入3.,然后按Tab键。有哪些方法可以被应用?scala> 3.% * - > >> ^ isInstanceOf toChar toFloat toLong toString unary_- |& + / >= >>> asInstanceOf toByte toDouble toInt toShort unary_+ unary_~scala> import scala.math._import scala.math._scala> sqrt(3)res1: Double = 1.7320508075688772scala> res1 * res1res2: Double = 2.9999999999999996scala> 3 - res2res3: Double = 4.440892098500626E-16 |
scala> res3=0<console>:16: error: reassignment to val res3=0 ^scala> "crazy" * 3res4: String = crazycrazycrazy- 在过滤框中输入 String - 选择 StringOps - 找到 * 方法,文档中的说明如下: def *(n: Int): String Return the current string concatenated n times. |
scala> import scala.util.Randomimport scala.util.Randomscala> import scala.math.BigInt._import scala.math.BigInt._scala> probablePrime(100,Random)res12: scala.math.BigInt = 1220680273650327122886980473381 |
scala> probablePrime(100,Random)res12: scala.math.BigInt = 1220680273650327122886980473381scala> probablePrime(100,Random).toString(36)res13: String = 2f1yebpp8l5ft8y2afh7scala> val str = "Hello"str: String = Helloscala> str(0)res14: Char = Hscala> str.headres16: Char = Hscala> str.lastres17: Char = o标签:
原文地址:http://www.cnblogs.com/chenjo/p/4436580.html