Skip to content

Commit

Permalink
Include specific execution conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Jun 5, 2024
1 parent b341dbc commit cc39163
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/examples/pass_maybe.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
-module(pass_maybe).

-if(?OTP_RELEASE >= 25).

-feature(maybe_expr, enable).

-endif.

-export([sum_numbers/2]).


-if(?OTP_RELEASE >= 25).
sum_numbers(Number1, Number2) ->
maybe
ValidNumber1 ?= validate_number(Number1),
Expand All @@ -14,6 +19,10 @@ sum_numbers(Number1, Number2) ->
{error, invalid_number} ->
{error, "One or both inputs are invalid numbers"}
end.
-else.
sum_numbers(Number1, Number2) ->
Number1 + Number2.
-endif.

validate_number(Number) when is_number(Number) ->
Number;
Expand Down

0 comments on commit cc39163

Please sign in to comment.