Skip to content

Instantly share code, notes, and snippets.

View dev-nyc's full-sized avatar
🤹‍♂️
pushing

khaled dev-nyc

🤹‍♂️
pushing
View GitHub Profile
I reviewed some common Ruby methods and grouped them by behavior.
Hopefully this helps someone else too.
[Please copy paste and fix typos, add/delete, improve from this Gist.](https://gist.github.com/dirkdirk/9209d7ea67ac57543975162713910224)
-
# Array
arr1 = [1,2,3,4]
arr2 = ['a', 'b', 'c', 'd']
def interleave(arr1, arr2)
newarr = []
arr1.each do |num|
newarr << num << arr2[arr1.index(num)]
end
p newarr
end
@dev-nyc
dev-nyc / tic
Last active May 27, 2016 00:08
``` ruby
BOARD = ["a1" , "a2" , "a3" , "b1" , "b2" , "b3" , "c1" , "c2" , "c3"]
MARKER =[]
user_array = []
computer_array = []
def prompt(message)
puts message
end
def win?(player_array)
def prompt(message)
puts("=>#{message}")
end
GAME = %w(rock paper scissors lizard spoke)
def shorten(input)
case input
when "p" , "P" , "paper"
input = "paper"
def prompt(message)
puts("=>#{message}")
end
GAME = %w(rock paper scissors lizard spoke)
def shorten_input(input)
case input
when "p" , "P" , "paper"
input = "paper"
# car loan calculator
def prompt(message)
puts("=>#{message}")
end
def number_valid(num)
num =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
end
def integer?(input)
# car loan calculator
# methods
def prompt(message)
puts("=>#{message}")
end
def number_valid(num)
num =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
end