KillerDesigner
10/6/2013 - 1:47 AM

arrayPrac.rb


# 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