Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Created April 24, 2017 12:48
Show Gist options
  • Save shahryarjb/504ee6f17df91a1d91b59015997fcbc7 to your computer and use it in GitHub Desktop.
Save shahryarjb/504ee6f17df91a1d91b59015997fcbc7 to your computer and use it in GitHub Desktop.
# my blog : https://trangell.com/fa/
# public : http://iranonrails.ir
authors = [
%{ name: "José", language: "Elixir" },
%{ name: "Matz", language: "Ruby" },
%{ name: "Larry", language: "Perl" }
]
languages_with_an_r = fn (:get, collection, next_fn) ->
for row <- collection do
if String.contains?(row.language, "r") do
next_fn.(row)
end
end
end
IO.inspect get_in(authors, [languages_with_an_r, :name])
#=> [ "José", nil, "Larry" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment