[关闭]
@Arslan6and6 2016-08-29T02:35:23.000000Z 字数 863 阅读 686

scala学习第一章 基础

scala学习


P10 implicit 自动隐式转换
image_1aqdmkjndob8118k1ui1r6o7b49.png-122.7kB

P12 scala> "helloworld".patch(1,"xxxxx",2)
res13: String = hxxxxxloworld
从原字符串第N+1位置起替换M个字符为指定字符串

第一章练习
scala> math.sqrt(3)
res33: Double = 1.7320508075688772
scala> math.pow(res33,2)
res35: Double = 2.9999999999999996
scala> 3-res35
res38: Double = 4.440892098500626E-16

scala> "crazy"*3
res39: String = crazycrazycrazy

scala> 10 max 2
res40: Int = 10

scala> BigInt(2).pow(1024)
res44: scala.math.BigInt = 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216

cala> "hello".take(1)
res55: String = h

scala> "hello".takeRight(1)
res56: String = o

scala> "hello".reverse
res57: String = olleh

scala> "hello".reverse.take(1)s
res58: String = o

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注