• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/6

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

6 Cards in this Set

  • Front
  • Back

Arrays

uses []


indexing -


indicies start at 0


minus counts backwords [-1]




PICKAXE p68

array[1,3]

returns new array [start,count]


anArray = [1,2,3,4,5,6]


anotherArray = anArray[2,3]


anotherArray = [3,4,5]




PICKAXE p68

array[2..5]


array[2...5]

2 dots = just me


3 dots = them and me


anArray = [1,2,3,4,5,6]


anotherArray = anArray[2..5]


anotherArray = [3,4]


Array2 = anArray[2...5]


Array2 = anArray[2,3,4,5]




PICKAXE p69

setting elemets in array

a = [1,2,3,4,5,6]


a[2] = L


a = [1,2,L,4,5,6]


a[8] = M # any inbetween values generated are nil


a = [1,2,L,4,5,6,nil,nil,M]


a[6] = [11,12] #can make 2d array


a = [1,2,L,4,5,6,[11,12],nil,M]




bonus points for using arrayposition and count to set new elemnts in(see pickaxe)


PICKAXE p69

.push .pop .unshit. shift

.push, add elements to end of array


.pop, remove elements from the end of the array,


useful for stacking things




.unshift add elemnts to front


.shift remove elemnt from front




queue = []


queue.push "red"


queue.push "green"


puts queue.shift


puts queue.shift


produces:


red


green








PICKAXEp68

.first .last

return the n indices from front or back, withour removing them from the array(still in order)




a=[1,2,3,4,5,6,7,8,9]


a.first(3)=[1,2,3]


a.last(3)=[7,8,9]




PICKAXEp70