Created
February 7, 2011 00:06
-
-
Save joshk/813845 to your computer and use it in GitHub Desktop.
This file contains 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 characters
diff --git a/lib/list.ex b/lib/list.ex | |
index 75778f7..10d6cf7 100644 | |
--- a/lib/list.ex | |
+++ b/lib/list.ex | |
@@ -1,5 +1,13 @@ | |
object List | |
- def +(another) | |
+ % Returns a new list with the contents of the | |
+ % current list and the other list. | |
+ % | |
+ % ## Examples | |
+ % | |
+ % [1,2,3] + [4,5,6] %=> [1,2,3,4,5,6] | |
+ % [1,2,3] + [1,2,3] %=> [1,2,3,1,2,3] | |
+ % | |
+def +(another) | |
Erlang.lists.append(self, another) | |
end | |
diff --git a/test/elixir/list_test.ex b/test/elixir/list_test.ex | |
index 5a369f0..bd79a0b 100644 | |
--- a/test/elixir/list_test.ex | |
+++ b/test/elixir/list_test.ex | |
@@ -6,4 +6,11 @@ object ListTest < ExUnit::Case | |
true = list.member?(1) | |
false = list.member?(4) | |
end | |
+ | |
+ def add_two_lists_together_test | |
+ list_one = [1,2,3] | |
+ list_two = [4,5,6] | |
+ [1,2,3,4,5,6] = list_one + list_two | |
+ [1,2,3,1,2,3] = list_one + list_one | |
+ end | |
end | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment