I'm sure whoever made this happen had put in a lot of effort, but as you said, I don't think it's ideal to just shoehorn a feature in when it doesn't fit in.
By the way, with a quick glance on your snippets below, it looks like what you're asking for isn't really justpattern matching, but rather method overload.
From what I know about Crystal, it has method overload only by types (much like Java). And hear it would be possible to also "overload" by particular values - for example different method for hash containing a key "success".
Correct, that's what overloading means - defining methods with same name but with different method signatures, and method signatures are usually types & arity.
What you're referring to (in Elixir) is a combination of both - when you have pattern matching, your method signatures aren't just types & arity, but also patterns.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Wow, that was really hard to understand!
I'm sure whoever made this happen had put in a lot of effort, but as you said, I don't think it's ideal to just shoehorn a feature in when it doesn't fit in.
By the way, with a quick glance on your snippets below, it looks like what you're asking for isn't really just
pattern matching, but rathermethod overload.I know Crystal has it which looks pretty cool!
From what I know about Crystal, it has method overload only by types (much like Java). And hear it would be possible to also "overload" by particular values - for example different method for hash containing a key "success".
Correct, that's what overloading means - defining methods with same name but with different method signatures, and method signatures are usually types & arity.
What you're referring to (in Elixir) is a combination of both - when you have pattern matching, your method signatures aren't just types & arity, but also patterns.