Acces implementation for List

81 views
Skip to first unread message

Szetty Szederjesi

unread,
Jan 5, 2015, 3:00:40 PM1/5/15
to elixir-l...@googlegroups.com
Hello everyone,

I wanted use the access operator ([]) for a normal list in Elixir, and I got an ArgumentError.

I look at the Access.ex and I realized that there is implementation for access just for keyword lists.

Why isn't there an implementation for a normal list too?

José Valim

unread,
Jan 5, 2015, 3:41:51 PM1/5/15
to elixir-l...@googlegroups.com
No, because the Access protocol is meant to be implemented by Dict like data structures and a list, generally speaking, is not a performant dictionary. The only exception is keyword lists which are meant to have at maximum a dozen keys!



José Valim
Skype: jv.ptec
Founder and Lead Developer

--
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-co...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Szetty Szederjesi

unread,
Jan 5, 2015, 4:01:58 PM1/5/15
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
Okay, I understood it.
Reply all
Reply to author
Forward
0 new messages