scala> "astron".to
to toBuffer toDouble toInt toList toMap toShort toTraversable
toArray toByte toFloat toIterable toLong toSeq toStream toUpperCase
toBoolean toCharArray toIndexedSeq toIterator toLowerCase toSet toString toVector
scala> "astron".to
res0: scala.collection.immutable.IndexedSeq[Char] = Vector(a, s, t, r, o, n)
scala> "astron".toBuffer
res1: scala.collection.mutable.Buffer[Char] = ArrayBuffer(a, s, t, r, o, n)
scala> "astron".toDouble
java.lang.NumberFormatException: For input string: "astron"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at scala.collection.immutable.StringLike$class.toDouble(StringLike.scala:284)
at scala.collection.immutable.StringOps.toDouble(StringOps.scala:29)
... 48 elided
scala> "astron".toInt
java.lang.NumberFormatException: For input string: "astron"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at scala.collection.immutable.StringLike$class.toInt(StringLike.scala:272)
at scala.collection.immutable.StringOps.toInt(StringOps.scala:29)
... 48 elided
scala> "astron".toList
res4: List[Char] = List(a, s, t, r, o, n)
scala> "astron".toMap
<console>:24: error: Cannot prove that Char <:< (T, U).
"astron".toMap
^
scala> "astron".toShort
java.lang.NumberFormatException: For input string: "astron"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Short.parseShort(Short.java:118)
at java.lang.Short.parseShort(Short.java:144)
at scala.collection.immutable.StringLike$class.toShort(StringLike.scala:268)
at scala.collection.immutable.StringOps.toShort(StringOps.scala:29)
... 48 elided
scala> "astron".toTraversable
res7: Traversable[Char] = astron
scala> "astron".toArray
res8: Array[Char] = Array(a, s, t, r, o, n)
scala> "astron".toByte
java.lang.NumberFormatException: For input string: "astron"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Byte.parseByte(Byte.java:149)
at java.lang.Byte.parseByte(Byte.java:175)
at scala.collection.immutable.StringLike$class.toByte(StringLike.scala:264)
at scala.collection.immutable.StringOps.toByte(StringOps.scala:29)
... 48 elided
scala> "astron".toFloat
java.lang.NumberFormatException: For input string: "astron"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at scala.collection.immutable.StringLike$class.toFloat(StringLike.scala:280)
at scala.collection.immutable.StringOps.toFloat(StringOps.scala:29)
... 48 elided
scala> "astron".toIterable
res11: Iterable[Char] = astron
scala> "astron".toLong
java.lang.NumberFormatException: For input string: "astron"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at scala.collection.immutable.StringLike$class.toLong(StringLike.scala:276)
at scala.collection.immutable.StringOps.toLong(StringOps.scala:29)
... 48 elided
scala> "astron".toSeq
res13: Seq[Char] = astron
scala> "astron".toStream
res14: scala.collection.immutable.Stream[Char] = Stream(a, ?)
scala> "astron".toUpperCase
res15: String = ASTRON
scala> "astron".toBoolean
java.lang.IllegalArgumentException: For input string: "astron"
at scala.collection.immutable.StringLike$class.parseBoolean(StringLike.scala:290)
at scala.collection.immutable.StringLike$class.toBoolean(StringLike.scala:260)
at scala.collection.immutable.StringOps.toBoolean(StringOps.scala:29)
... 48 elided
scala> "astron".toCharArray
res17: Array[Char] = Array(a, s, t, r, o, n)
scala> "astron".toIndexedSeq
res18: scala.collection.immutable.IndexedSeq[Char] = Vector(a, s, t, r, o, n)
scala> "astron".toIterator
res19: Iterator[Char] = non-empty iterator
scala> "astron".toLowerCase
res20: String = astron
scala> "astron".toSet
res21: scala.collection.immutable.Set[Char] = Set(s, n, t, a, r, o)
scala> "astron".toString
res22: String = astron
scala> "astron".toVector
res23: Vector[Char] = Vector(a, s, t, r, o, n)
spark to函数
最新推荐文章于 2024-10-15 11:38:13 发布