[erlang-questions] Using match in guards

caio ariede caio.ariede@REDACTED
Tue Dec 22 01:37:06 CET 2009


Very thanks Dale.

test(N) when element(1, N) == regex -> ...

..do the trick! :)

I think the is_tuple/1 is not really needed.

Caio Ariede
http://caioariede.com/



On Mon, Dec 21, 2009 at 9:49 PM, Robert Virding <rvirding@REDACTED> wrote:
> No, you cannot do pattern matching in guards.
>
> It has been discussed and would be possible, but for now you can't.
>
> Robert
>
> 2009/12/22 caio ariede <caio.ariede@REDACTED>
>>
>> In function guards we can use functions like is_string/1 and is_number/1.
>>
>> But I'm needing to check a generic type defined by {type, Value} but
>> *in guards* like this:
>>
>> search(S) when N = {regex, _} ->
>> ...
>>
>> I know that I can do that with search(S = {regex, _}), but my example
>> was only for representing the problem.
>>
>> The main question is: there is a way for using match in guards? Or
>> something like this?
>>
>> Caio Ariede
>> http://caioariede.com/
>>
>> ________________________________________________________________
>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>> erlang-questions (at) erlang.org
>>
>
>


More information about the erlang-questions mailing list