A thread for questions on Getting Started with Reason Egghead Course
Reason Video Course Discussion
idkjs
#2
In rtop, creating the switch apparently requires you going to the next line. Worth noting for rookies the next time. I’ve been avoiding rtop and had to try a few time like below.
Reason # let lamp = switch(1) {|0 => "off" |1 => "on"};
Interrupted.
Reason # let lamp =
switch (1){| 0 => "off" | 1 => "on"};
Interrupted.
Reason # let lamp =
switch (1) {
| 0 => "off"
| 1 => "on"
};
Characters 12-51:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
2
let lamp: string = "on";
Reason #
sgrove
#3
I think the case here may be {| ... |}
is the notation for multi-line strings. I suspect that if you put a space between {
and |
, e.g. switch { | 0 => "off" | 1 => "on" }
, it may work.
@chenglou this has caught a number of people (including me) when first getting started, perhaps it’s a special case we can recognize (at least outside of rtop
)?