Created
February 6, 2016 03:40
-
-
Save sandeshsoni/6bb12b18e965ce77155f to your computer and use it in GitHub Desktop.
Revisions
-
Sandesh Soni revised this gist
Feb 6, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,13 +11,13 @@ defmodule ModuleName do # this is a module end defmodule SomeModule do def public_method do end end # called as public_method or SomeModule.public_method defmodule SomeModule do defp private_method do end end -
Sandesh Soni created this gist
Feb 6, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ # This is a comment # The first thing in any language next_integer_after = fn x -> x+1 end # This is an annoymous function. # called inside function as next_integer_after(3) defmodule ModuleName do # this is a module end defmod SomeModule do def public_method do end end # called as public_method or SomeModule.public_method defmod SomeModule do defp private_method do end end # called inside module by just private_method # one more common stuff we do. Concatenation of strings first_name = "lorem" last_name = "epsum" full_name = first_name <> " " <> last_name # lets make it a simple anonymous function, greet_person = fn {greeting, first_name, last_name} -> greeting <> first_name <> last_name end # But we may not always have greeting present. # How about default greet ? greet_person = fn {greeting // "hi", first_name, last_name} -> greeting <> first_name <> last_name end called as greet_person.({"good morning", "Anil", "W"}) # But we are so many people here. # ok, lets have one more. greet_team = fn when {greeting // "hi", team} -> greeting <> " " <> team end {greeting // "hi", first_name, last_name} -> greeting <> first_name <> last_name end