Giter VIP home page Giter VIP logo

Comments (4)

vmihailenco avatar vmihailenco commented on August 11, 2024

I have nothing against having a switch statement, but ClickHouse also has multiIf function with short-circuit-function-evaluation. It is often more readable than a switch and addresses your concerns about "evaluate all conditions and cases before choosing a correct one".

from expr.

antonmedv avatar antonmedv commented on August 11, 2024

While switch statement is easy to understand and implement, maybe we need to consider adding "match" expression instead.

Or to make expr closer to golang and implement switch in the exact same semantics.

from expr.

vmihailenco avatar vmihailenco commented on August 11, 2024

Or to make expr closer to golang and implement switch in the exact same semantics.

I very much would like to see multi-line expressions happen, so it would make sense to have switches to be an expression as well, e.g. in Ruby:

case x
when 1..5
  "It's between 1 and 5"
when 6
  "It's 6"
when "foo", "bar"
  "It's either foo or bar"
else
  "You gave me #{x} -- I have no idea what to do with that."
end

The key point is that it evaluates to an expression. The syntax does not matter.

from expr.

antonmedv avatar antonmedv commented on August 11, 2024

I see. This makes sense. ๐Ÿ‘๐Ÿป

from expr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.