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 642169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:08:31+00:00 2026-05-13T21:08:31+00:00

Just to clarify, when I say multiple assigment, parallel assignment, destructuring bind I mean

  • 0

Just to clarify, when I say multiple assigment, parallel assignment, destructuring bind I mean the following pattern matching gem

scala> val (x,y) = Tuple2("one",1)
x: java.lang.String = one
y: Int = 1

which assigns "one" to x and 1 to y.

I was trying to do

val (x,y) = "a b".split()

I was expecting that scala would attempt to pattern match the array with the pattern, and would throw a runtime exception if the length of the array wouldn’t match the length of the pattern.

All my attempts to easily convert an Array to a Tuple2 were futile.

scala> Tuple2(Array(1,2):_*)
<console>:7: error: wrong number of arguments for method apply: (T1,T2)(T1, T2)
in object Tuple2
       Tuple2(Array(1,2):_*)
       ^

scala> Tuple2(Array(1,2).toList:_*)
<console>:7: error: wrong number of arguments for method apply: (T1,T2)(T1, T2)
in object Tuple2
       Tuple2(Array(1,2).toList:_*)

Is there any neat way to use multiple assignment with arrays or lists?

  • 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-05-13T21:08:31+00:00Added an answer on May 13, 2026 at 9:08 pm

    All you need to do is make your val side (left of the =) compatible with your initializer (right of the =):

    scala> val Array(x, y, z) = "XXX,YYY,ZZZ".split(",")
    x: java.lang.String = XXX
    y: java.lang.String = YYY
    z: java.lang.String = ZZZ
    

    As you expected, a scala.MatchError will be thrown at runtime if the array size don’t match (isn’t 3, in the above example).

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Edit: Add the -mwindows flag when compiling. May 16, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer If you have access to the Kernel object created at… May 16, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer Bernina's .ART format is indeed proprietary, but Berinina owns a… May 16, 2026 at 4:02 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

EDIT Just to clarify, there is no intent of putting this into production. Purely
A fairly basic question, but I don't see it asked anywhere. Let's say we
I just gave an answer to a quite simple question by using an extension
To clarify: I'm not using the gettext php module /extension, reason being because I
Is it possible for a website to allow users to log in via multiple
I have the following challenge, and I haven't found a good answer. I am
Before anything, let me first clarify that the below thoughts are purely my personal
When I try to build my setup project, I get the following error: An
I am using a method that has the following signature: public static bool TryAuthenticate(string
I have an Account model and a User model: class Account < ActiveRecord::Base has_many

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.