Skip to content

Instantly share code, notes, and snippets.

@bellthoven
Created April 9, 2012 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bellthoven/2343470 to your computer and use it in GitHub Desktop.
Save bellthoven/2343470 to your computer and use it in GitHub Desktop.
Access orddict by strings
diff --git a/lib/access.ex b/lib/access.ex
index 009fdf2..1b3d396 100644
--- a/lib/access.ex
+++ b/lib/access.ex
@@ -27,6 +27,10 @@ defimpl Access, for: List do
atom_access(list, atom)
end
+ def access(list, binary) when is_binary(binary) do
+ atom_access(list, binary_to_atom(binary))
+ end
+
## Regex
def access(list, re) when is_regex(re) do
@@ -78,4 +82,4 @@ defimpl Access, for: Function do
def access(function, item) do
function.(item)
end
-end
\ No newline at end of file
+end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment