I'm attempting to create a T-SQL case statement to filter a query based on whether a field is NULL or if it contains a value. It would be simple if you could assign NULL or NOT NULL as the result of a case but that doesn't appear possible.
Here's the psuedocode:
WHERE DateColumn = CASE @BitInput
WHEN 0 THEN (all null dates)
WHEN ...
Possible Duplicates:
is else if faster than switch() case ?
What is the relative performance difference of if/else versus switch statement in Java?
I know that case statements can be implemented with jump tables. Does this make them more efficient than if statements?
Is this just mico-optimization that should be avoided?...
If I compare a string literal to a string literal using the case statement, I get the expected behavior: if they are the same - it matches, if they are not - it does not.
However, if I compare a string literal to a constant that is a string, I get "Pattern matches are overlapped" warning and the branch with the constant always matches.
...
I'm having a slow morning. I thought referencing an existing val in a case statement would be OK. But it seems it is interpreted as a local variable definition. A rudimentary googling didn't help and I don't have my staircase book with me.
In the following, what is the syntax that would allow me to match on case (b,c)?
scala> val (a,b,...
I'm getting a curious warning when pattern matching, but only when OverloadedStrings is enabled...
$ ghci -Wall
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let f x = case...
What is the difference between
case item.class
when MyClass
# do something here
when Array
# do something different here
when String
# do a third thing
end
and
case item.class
when MyClass.class
# do something here
when Array.class
# do something different here
when String.class
# do a third thing
end
For some reason, ...