--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20160811223043.7a17eb02.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.
def something_magical(x) when is_any(x, [:integer, :float, :list, :map]) do #...
end
def something_magical(x) when is_integer(x) or is_float(x) or is_list(x) or is_map(x) do
#...
end
is_any(x, [List, Map, Tuple])
thank you for your answer José,
I can look into how we can add new kinds (I will need help with
defining how to deal with conflicting kinds).
I think the defguard approach is reasonable, but I thought it was
ditched for some reason.
What we could do is create a defkind macro that uses defguard, but
creates kinds only (since defguard can create any kind of guard).
defmodule DateTimedef new(..., seconds) when seconds is [{:gte, 0}, {:lte, 60}] do
defmoduel DateTime
defguard is_seconds(seconds) when seconds >= 0 and seconds <= 60
def new(..., seconds) when is_seconds(seconds)
end
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20160813012725.77f2ad33.eksperimental%40autistici.org.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TsXEu%3DGFrVayYdvfEA0%3DGtG%3DJsPUj9CzoSyXw2eqA5r7g%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20160813022209.5a991c28.eksperimental%40autistici.org.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TviuNP1gAiN6tR0C%2BKAFXj_uCXxzcYnib5Dv7FdNFwujw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4J2DJN41Z_Twe5VpQ4p6nx02N968OPrKyp0MUWO4p%3D%3DDQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20170602072926.530696ae.eksperimental%40autistici.org.