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

  • Home
  • SEARCH
  • 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 6562913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:45:59+00:00 2026-05-25T13:45:59+00:00

switch @user && @other when ‘user’ && true … when ‘user2’ && false …

  • 0
switch @user && @other
    when 'user' && true
        ...
    when 'user2' && false
       ...

Is something like this possible? It’s not working for some reason. Thanks!

  • 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-25T13:46:00+00:00Added an answer on May 25, 2026 at 1:46 pm

    It’s a pity that JS doesn’t think [1, 2] === [1, 2] (since they’re different references); otherwise you could use arrays to do what you want.

    Instead, here’s a function:

    multiSwitch = (values, cases...) ->
      for c in cases
        match = true
        for i in [0...values.length]
          unless c[i] is values[i]
            match = false
            break
        return c[values.length]() if match
      return
    

    Use it like this:

    multiSwitch [@user, @other],
      ['user', true, ->
        console.log 'case 1'
      ]
      ['user2', false, ->
        console.log 'case 2'
      ]
    

    Depending on what you’re doing, it may be easier to, say, concatenate your multiple values into a string and do a switch on that.

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

Sidebar

Related Questions

I am a happy BASH user. I do not want to switch to another
I'm using this in my main loop: if (SDL_WaitEvent(&event)) { switch (event.type) { case
I am wondering if something like this could be done(of course what I have
User can switch active application by Alt+Tab or by clicking on their icons in
What is the command-line equivalent of Switch Port Client User as found in the
Switch statements are typically faster than equivalent if-else-if statements (as e.g. descibed in this
Is that possible to switch an Open Source Project license from GPL to LGPL
Is there a way to store user inputs in switch case from one operation
I have this snippet of code (AJAX) in jQuery. $.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon='
Switch statement fallthrough is one of my personal major reasons for loving switch vs.

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.