Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:41:34+00:00 2026-06-16T02:41:34+00:00

Im learning Scala now, im trying to pass a tuple to a function that

  • 0

Im learning Scala now, im trying to pass a tuple to a function that prints all elements with for loop. This is what ive done so far but obviously something went wrong.

object Tuple_demo {
    def main(args: Array[String])
    {
      var tup1=(10,"test",6.8)
      printMe(tup1)
    }
    def printMe(tup1:Tuple1)
    {
      for (ob<-tup1)
      {
        println(ob)
      }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:41:35+00:00Added an answer on June 16, 2026 at 2:41 am

    All Scala Tuples extend Product. You can use its productIterator to iterate over tuple items:

    scala> (10,"test",6.8).productIterator.foreach(println)
    10
    test
    6.8
    

    The type declaration of your printMe function is incorrect. It should be a 3-ary tuple with types of its items specified, i.e. tup1: Tuple3[Int, String, Double]. Also, Scala has a sugar for tuple type declarations, so the following would also be correct: tup1: (Int, String, Double).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning Scala for the past couple of months and now I
I'm learning Scala, so this is probably pretty noob-irific. I want to have a
I'm learning Scala and there is a thing that I can't find out about
I am starting to I am learning scala, and trying to build some simple
Well, I'm learning Scala so this question may be too basic for most people.
I am new to Scala, just started learning, so this is basic beginner question.
I have just started learning Scala and I'm now wondering how I could implement
I'm just learning scala, and I wrote the hello,world program like this: object HelloWorld
So I'm learning Scala and came across some examples like this: val doubleEven =
I'm learning Scala and trying to use javax.cache in Scala code and can't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.