Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Dos condiciones exclusivas junto con una o condición para dos valores en la declaración de cambio

¿Hay alguna manera de hacer

 switch (expr) { case space or tab: print 'one of em + ' case space: print 'space' case tab: print 'tab' }
Aporte Producción
pestaña uno de ellos + pestaña
espacio uno de em + espacio

si no, cuales son las alternativas? Sé que podría usar if else pero como solo estoy usando una expresión como entrada, switch parece más apropiado

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No puedes hacer esto con un switch .

Pero if es realmente simple y legible:

 if (expr == space || expr == tab) print 'one of em + ' if (expr == space) print 'space' else if (expr == tab) print 'tab'

o mejor:

 if (expr == space || expr == tab) { print 'one of em + ' if (expr == space) print 'space' else if (expr == tab) print 'tab' }

o mejor:

 if (expr == space || expr == tab) { print 'one of em + ' if (expr == space) print 'space' else // if (expr == tab) is not needed because print 'tab' // tab is the only possible outcome here. }

Todo el código anterior es pseudocódigo.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!