Skip to content

Commit

Permalink
Create Array Excersise 2
Browse files Browse the repository at this point in the history
In the first program the method on line two combines the array [1, 2, 3] with ["a", "b"]. Then in the third line of code it selects the first element of the array, ["b", 1] then uses the delete operator to delete the first.last of the arr array which happens to be 1. The program returns 1.

In the second program it runs exactly the same except for the Array(1..3) is now nested as Array([1..3)]. After the product conversion arr instead becomes ["b", [1, 2, 3]], ["a", [1, 2, 3]]. In line three it once again removes the last element of the first element of arr and returns with [1, 2, 3].
  • Loading branch information
raspy8766 committed Sep 2, 2014
1 parent aff1544 commit 852b0b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Array Excersise 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1. returns 1
arr = [["b"], ["b", 2], ["b", 3], ["a", 1], ["a", 2], ["a", 3]]

2. returns [1, 2, 3]
arr = [["b"], ["a", [1, 2, 3]]]

0 comments on commit 852b0b0

Please sign in to comment.