Skip to content

Instantly share code, notes, and snippets.

View amorphid's full-sized avatar

Michael Pope amorphid

  • Digital Turbine
  • San Francisco, CA
View GitHub Profile
# your local variables
first_card = 11
second_card = 13
# The "card" variable can only be seen within the method
def check_face_card(card) # removed the space
if card == 11 || card == 12 || card == 13
card = 10
else
end
@amorphid
amorphid / gist:5368246
Created April 12, 2013 00:12
String class w/ length and reverse
class String
def how_long_am_i?
length = 0
while self[length] != nil
length += 1
end
length
end
@amorphid
amorphid / gist:5356720
Created April 10, 2013 17:34
Basic way to calculate length of a string
# breaks if string includes a 0
def string_length(a)
string = a + "0"
length = 0
while string[length] != "0"
length += 1
end
puts "Your statement is #{length} characters long"