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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:20:35+00:00 2026-05-27T01:20:35+00:00

After reading this answer I’ve tried to play with this nice feature by myself

  • 0

After reading this answer I’ve tried to play with this nice feature by myself and found out that it is ok when I’m do

scala> val Array(a,b,n) = "XXX,YYY,ZZZ".split(",")
a: java.lang.String = XXX
b: java.lang.String = YYY
n: java.lang.String = ZZZ

But is not ok with uppercase named variable:

scala> val Array(a,b,N) = "XXX,YYY,ZZZ".split(",")
<console>:9: error: not found: value N
       val Array(a,b,N) = "XXX,YYY,ZZZ".split(",")

What is the reason of such behavior?

UPD
Actually, the same thing with tuples assigment:

scala> val (a,b,N) = (1,2,3)
<console>:9: error: not found: value N
       val (a,b,N) = (1,2,3)
  • 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-27T01:20:35+00:00Added an answer on May 27, 2026 at 1:20 am

    Scala treats it as a constant against which to match the pattern. Observe:

    scala> val N = 20
    N: Int = 20
    
    scala> val Array(a, b, N) = Array(11, 23, 20)
    a: Int = 11
    b: Int = 23
    
    scala> val Array(a, b, N) = Array(11, 23, 21)
    scala.MatchError: [I@195d471 (of class [I)
            at .<init>(<console>:75)
            at .<clinit>(<console>)
            at .<init>(<console>:11)
            at .<clinit>(<console>)
            at $print(<console>)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
            at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
            at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
            at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
            at java.lang.Thread.run(Thread.java:662)
    

    The variables in which you want to extract the values must begin with a lower-case letter.

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

Sidebar

Related Questions

After reading the answer to this question , I learned that SFINAE can be
After reading this answer: best way to pick a random subset from a collection?
After reading this question , i saw the answer by Naveen containing a link
After reading the nice answers in this question , I watched the screencasts by
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
I have this question after reading the answer here , what's the difference at
I'm trying to understand how to use Type Converters after reading this answer to
Edit: After reading the responses, I believe the answer is don't do this, hence
(Title and contents updated after reading Alex's answer) In general I believe that it's

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.