Created
September 24, 2013 19:22
-
-
Save OfTheDelmer/6689911 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
# We want a method that splits an array on an index and | |
# removes everything afterward | |
# Example: myArray = [1, 2, 3, 4, 5, 6] | |
# splice(3, myArray) => [1,2,3,4] | |
myArray = [1,2,3,4,5,6] | |
puts "Give my an index" | |
index = gets.chomp().to_i | |
# Try using a loop and creating a new Array, (maybe shovel) | |
x =0 | |
newArray = [] | |
while x < index | |
# do stuff here | |
newArray << myArray[x] | |
x += 1 | |
end | |
p newArray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment