3 ms·
> I understand why with could not work with the = matching operator (it's a macro) Not sure what you mean - `with` _can_ use the `=` operator, e.g. you could w
by arrowsmith 3y ago
> I understand why with could not work with the = matching operator (it's a macro)
Not sure what you mean - `with` _can_ use the `=` operator, e.g. you could write:
with true = is_email_address?(email),
true = EmailAddresses.is_available(email) do
# something
end
Although this is rather pointless as it's functionally equivalent to just writing:
true = is_email_address?(email)
true = EmailAddresses.is_available(email)
# something
`=` is useful inside `with` if you have a clause that _must_ return a particular value or it's an error, i.e. you don't need to match on any other possible return value. But if you don't have at least one clause with `<-` then `with` achieves nothing.
Also, why would the fact that `with` is a macro mean that it can't use `=`?