In with <- matches the value on the right to the pattern on the left, only continuing if they match. The difference is that "for" traverses the collection on the right while "with" takes the value on the right at "face value". = has the same meaning on both expressions which is the same as in any other Elixir code. In other words, <- slightly changes its meaning based on the wrapping construct.
*José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Sat, Jul 30, 2016 at 11:03 AM, Pierre de Lacroix <[email protected]> wrote: > OK, because it's in a for. I've seen that both could be used in a with > construct too, do they have the same meaning in this case ? > > > Le 29 juillet 2016 15:40:04 GMT+02:00, "José Valim" < > [email protected]> a écrit : >> >> <- will traverse the collection on the right side matching each element >> with the pattern on the left side. = is the = we all know and love. >> >> On Friday, July 29, 2016, Pierre de Lacroix <[email protected]> wrote: >> >>> In a comprehension like this, what's the difference between pattern >>> matching with "<-" and "=" ? >>> >>> On Wed, 27 Jul 2016 05:20:09 +0000 >>> Peter Hamilton <[email protected]> wrote: >>> >>> > This is a fairly straightforward (though a bit long) for >>> > comprehension: >>> > >>> > for {room_id, room} <- data, >>> > {date, obj} <- room, >>> > stuff = obj["important_stuff"], >>> > {child_id, child} <- stuff, >>> > child_id != "id" do >>> > %{ >>> > room_id: room_id, >>> > date: date, >>> > ... >>> > } >>> > end >>> > >>> > On Tue, Jul 26, 2016, 9:45 PM Sam Hains <[email protected]> wrote: >>> > >>> > > That should read: triple nested Enum.each **** >>> > > >>> > > -- >>> > > 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 [email protected]. >>> > > To view this discussion on the web visit >>> > > >>> https://groups.google.com/d/msgid/elixir-lang-talk/44849237-d460-4760-ad3d-4ced90c9f96c%40googlegroups.com >>> > > < >>> https://groups.google.com/d/msgid/elixir-lang-talk/44849237-d460-4760-ad3d-4ced90c9f96c%40googlegroups.com?utm_medium=email&utm_source=footer >>> > >>> > > . >>> > > 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-talk/20160729153309.7e557ad9%40ArchPierre2 >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- > Envoyé de mon appareil Android avec K-9 Mail. Veuillez excuser ma brièveté. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-talk/151BBF7E-59C6-45F4-9DA3-5D7C214FCD80%40gmx.com > <https://groups.google.com/d/msgid/elixir-lang-talk/151BBF7E-59C6-45F4-9DA3-5D7C214FCD80%40gmx.com?utm_medium=email&utm_source=footer> > . > > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAGnRm4KGSGE_1%2BSTM4FVwBwr8Yg6htkr%3Dh%3DYqNBwPc8mX4bohw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
