The other *_in use case that I find clunkier with structs is piping a struct through multiple *_in functions isn’t as nice.
e.g. with a map you can just do map |> update_in([:some_key, …], &(…)) |> update_in([:other_key, …], &(…)) but with a struct you have to do something like update_in(struct.some_key.etc, &(…)) |> update_in([Access.key!(:other_key), …], &(…)) I’ve also found myself at times either not defining a struct where I could, or even implementing the Access behaviour on modules that do define a struct by delegating functions to Map if I find myself doing these kinds of pipelines frequently. Adam On Wed, Dec 7, 2016 at 6:50 PM, Michał Muskała <[email protected]> wrote: > Good evening everybody. > > This is a moved discussion from https://github.com/elixir- > lang/elixir/issues/5548#issuecomment-265602755. > > Today, there's no way to work with structs in an easy way for the _in > functions. > > For static keys, everything is nice and shiny when working with both maps > and structs: > > update_in(foo.bar.buz, &(...)) > > Unfortunately as soon as we need to introduce a dynamic value, it suddenly > becomes extremely clunky in case of structs: > > update_in(foo.bar[key], &(...)) > # vs > update_in(foo, [Access.key!(:bar), Access.key(key)], &(...)) > > This is generally pushing me to work more with unstructured data in forms > of maps, the usability difference is huge. The Access is a very powerful > tool that helps to solve many problems in a concise way, it's unfortunate > structs have such a poor support. > > Michał. > > -- > 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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/4299E5C9-9C9B-411F-90FA-9EF7B6900327%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-core" 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-core/CABqbXnsKbNdNb9t7yA9MMakW%2BOvWFFn9ThvUTRWGRCsOHyRvyA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
