[erlang-questions] I think I wish I could write case Any of whatever -> _ end.
Nicholas Frechette
zeno490@REDACTED
Fri May 14 21:13:09 CEST 2010
This looks like an assert to me? You just want to ensure that Any is
matching the very long pattern, correct?
In that case, you may be better off with an assert macro, something like:
?ASSERT_MATCH(Any, very_long_pattern_or_whatever).
And write ASSERT_MATCH yourself.
You can also write it as:
very_long_pattern_or_whatever = Any.
Although guards may not work in the later.
You can also make it a single function that you'll call:
ensure_whatever(Any) when some_guards -> very_long_pattern_or_whatever =
Any.
That way you might get better debugging info if what you pass to
ensure_whatever does not match.
2cents
On Fri, May 14, 2010 at 3:05 PM, Eric Newhuis (personal) <enewhuis@REDACTED
> wrote:
> Consider:
>
> X = case Any of
> very_long_pattern_or_whatever ->
> very_long_pattern_or_whatever
> end.
>
>
> I'd rather abbreviate that like this.
>
> X = case Any of
> very_long_pattern_or_whatever -> _
> end.
>
> It also seems more readable to me than:
>
> X = case Any of
> very_long_pattern_or_whatever=Y -> Y
> end.
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list