How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread auxym
You might like this blog post with other similar patterns:

How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread xigoi
Mutability should be restricted as much as possible, to make it easier to reason about code. C++ programmers like to talk about “const-correctness”, but C++ makes it very difficult to restrict mutability.

How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread Araq
> The language is a tool. No, tools disappear once the house has been built. A language really is building material. Connecting wood with stone is harder than putting stone on top of stone.

How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread kobi
defecting, hehe. The loyalty value used to bother me too. It is silly, actually. The language is a tool. Just like when a problem needs a screwdriver instead of a hammer, don't feel guilty for being disloyal to the hammer. btw, what is wrong with using a top level `var`? (declaring a var before

How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread cblake
There are a few constructs just like that where analogy making from the constraints of other programming languages fail you. A similar example is try-except expressions. I.e., this works: import tables var t: Table[int, int] let x = try: t[0] except: 1 Run

How to declare a varible in a case statement for use afterwrads

2022-10-08 Thread halloleo
Very cool! So elegant! Now where you said it, it feels so obvious...

How to declare a varible in a case statement for use afterwrads

2022-10-06 Thread ElegantBeef
You use an expression: let msg = case location of locHere: "I'm here!" of loThere: "You're there!" Run

How to declare a varible in a case statement for use afterwrads

2022-10-06 Thread Araq
let msg = case location of locHere: "I'm here!" of loThere: "You're there!" echo &"And Shakespeare said: {msg}" Run Side note: Python sucks.

How to declare a varible in a case statement for use afterwrads

2022-10-06 Thread halloleo
I use an Enum like this: LocationOption* = enum locHere, locThere Run and have then the following program construct: case location of locHere: let msg = "I'm here!" of loThere: let msg = "You're there!" echo &"And Shakesp