samedi 10 mars 2018

How to get random elements from a map in Elixir?

I have an Elixir map:

iex(1)> my_map = %{a: "one", b: "two", c: "three"}
%{a: "one", b: "two", c: "three"}

I'd like to know how to get from this map:

  • A random element
  • A random key
  • A random value
  • Multiple random elements

How can I do this?




Aucun commentaire:

Enregistrer un commentaire