4 ms·
> Also you can't pattern match on a function return value IIRC. You definitely can. A function return value is just any other value and you can pattern match o
by marcofiset 4y ago
> Also you can't pattern match on a function return value IIRC.
You definitely can. A function return value is just any other value and you can pattern match on it directly, or with the `case` or `with` constructs.
- throwawaymaths 4y agoI think the poster means "you can't pattern match with a function value
- marcofiset 4y agoI don't see how this would be useful.
- conradfr 4y agoWhat would be the correct way to pattern match here? def foo(<I want to pattern match the value returned by GreatModule.constant_substitute()>), do: "bar" def foo(value), do: value
- marcofiset 4y agoUse a `case` in the body of the function. Why do you absolutely need to pattern match in the function header?