It has no meaning syntactically. It's just part of the function name. It is however a convention (especially common in Ruby) meaning "this function returns a boolean value".
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAEM0BxPu0w0pCpuNXzktOUUwpymxH7cyTTu3EgUePtKOX86vJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi
The convention is to end a function name with a ? if it returns a
boolean value. Otherwise it has no specific meaning.
Cheers,
Louis
On 21 August 2016 at 18:36, António Ramos <ramst...@gmail.com> wrote:
> Hello simple question for sure
>
> what is the meaning of the ? in
>
> def aaa?()
>
> regards
> António
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-talk+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-talk/CAEM0BxPu0w0pCpuNXzktOUUwpymxH7cyTTu3EgUePtKOX86vJA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAM-pwt7Cwi_LAvVWuk879ULfFLAs4USjdUEJxTMADEzW9Df%3DSA%40mail.gmail.com.
It has no meaning syntactically. It's just part of the function name. It is however a convention (especially common in Ruby) meaning "this function returns a boolean value".
On Sun, Aug 21, 2016, 10:37 AM António Ramos <ramst...@gmail.com> wrote:
Hello simple question for sure--what is the meaning of the ? indef aaa?()regardsAntónio
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAEM0BxPu0w0pCpuNXzktOUUwpymxH7cyTTu3EgUePtKOX86vJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAOMhEnyyRKa-mi7roBci-MvcNiFGEwL4mzPOdTo96%3D0%3DK-h0eQ%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/DE691B14-076D-4FE1-B9B6-9E76FC7890A0%40muskala.eu.
I think there's a stronger argument to be made for literal true / false, not just truthy / falsy in Elixir than Ruby.In Ruby, the return value might be used in an if-condition. Semantically, it shouldn't matter if the value is literal true or simply truthy. Something like `if method? == true` would be considered bad code.In Elixir, you might also use the value in pattern matching. Matching on literal `true` would be considered completely reasonable. Example:def entrypoint(data), do: handle(data, valid?(data))def handle(data, true), do: something(data)def handle(data, false), do: something_else(data)Returning truthy / falsy values would hobble this sort of pattern matching. It would be even worse if I only did a literal match on false, and ignored the in the true case, which would then be run for the falsy value nil.Another consideration is that a truthy value could potentially be large, and could then be sent off in a message to another process in the expectation that it's small.So please, return literal true / false from your predicate functions.- Martin
ons 24 aug. 2016 kl 15:28 skrev Michał Muskała <mic...@muskala.eu>:
> On 24 Aug 2016, at 15:24, Elliot Crosby-McCullough <elli...@gmail.com> wrote:
>
> Follow-up question; there's debate in Ruby as to whether methods ending in `?` are supposed to return actual booleans or just "truthy" and "falsy" values.
>
> Is there a similar debate in Elixir or has it been more strictly defined?
I've heard José state, that if it were possible, it would be an error for a ? function to return a non-boolean. I am equally of conviction that only strictly boolean values make sense in this context.
Michał.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/DE691B14-076D-4FE1-B9B6-9E76FC7890A0%40muskala.eu.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAAHw6C%2B2mL7zHOyVsFJ1UzSg9wVFrjcbc7sWGeEY%2B%3D9987nDpw%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.