Simple question about tuple of scala -


I'm new to Scala, and what I'm learning is taple .

>

I can define a tuple as the following, and get the items:

  val tuple = ("Mike", 40, "New York ") Println (" name: "+ tuple .0)  

How to get the length of tubal?

  • Is Tupal Unstable? Can I modify my items?
  • Is there any other useful operation that we can do on tuple?

    Thanks in advance! <

    1] Tupel.product error

    2] No.

    3] Some interesting operations you can do on Tupla: (a small REPL session)

      scala> Val x = (3, "hello") x: (int, java.lang.String) = (3, hello) scale & gt; X.swap res0: (java.lang.String, Int) = (Hello, 3) Skal & gt; X.toString res1: java.lang.String = (3, hello) scale & gt; Val y = (3, "hello") y: (int, java.lang.String) = (3, hello) scale & gt; X == y res2: Boolean = true scale & gt; X.productPrefix res3: java.lang.String = Tuple2 scala & gt; Val xi = x.productIterator xi: Itater [any] = empty eater scale & gt; While (xi.hasNext) println (xi.next) Hello 3  

    See scaladocs for more, etc.


  • Comments

    Popular posts from this blog

    c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

    Calling GetGUIThreadInfo from Outlook VBA -

    Obfuscating Python code? -