I hereby claim:
- I am estebanrules on github.
- I am estebanrules (https://keybase.io/estebanrules) on keybase.
- I have a public key whose fingerprint is 1EDD E685 401E 3121 D5D5 68E7 F959 72A8 98F0 409F
To claim this, I am signing this object:
enum SuperManIdentityError: ErrorType { | |
case WrongSecretIdentityError | |
} | |
func isSuperManTest(testWithSecretIdentity secretIdentity: String) throws -> String { | |
if secretIdentity != "Clark Kent" { | |
throw SuperManIdentityError.WrongSecretIdentityError | |
} | |
return secretIdentity | |
} |
// Ghetto Way | |
var numbers : [Int] = [] | |
func multiplesOfThreeAndFive(range1: Int, range2: Int) -> Int { | |
for i in range1..<range2 { | |
if i % 3 == 0 || i % 5 == 0 { | |
numbers.append(i) | |
} | |
} | |
let sumOfMultiples = numbers.reduce(0, combine: +) | |
return sumOfMultiples |
# test from iGist app | |
puts "Hello Underworld" |
I hereby claim:
To claim this, I am signing this object:
# Given a string, replace every instance of sad to happy | |
# | |
# add_more_ruby("The clowns were sad.") # => "The clowns were happy." | |
# add_more_ruby("The sad dad said sad stuff.") # => "The happy dad said happy stuff." | |
# add_more_ruby("Sad times are ahead!") # => "Happy times are ahead!" | |
def add_more_ruby(string) | |
string.gsub(/[sS]ad/, 'sad' => 'happy', 'Sad' => 'Happy') | |
end |
# First, make a Hash with a title of a movie, give it a rating. | |
movies = Hash.new | |
puts "What would you like to do?" | |
choice = gets.chomp | |
case choice | |
when "add" |
I hereby claim:
To claim this, I am signing this object:
# Fibonacci sequence with yield / parallel assignment | |
def fib_up_to(max) | |
i1, i2, = 1, 1 # parallel assignment | |
while i1 <= max | |
yield i1 | |
i1, i2 = i2, i1 + i2 | |
end | |
end | |
fib_up_to(1000) { |f| print f, " " } |
# Outputs a Fibonacci sequence, the length of the sequence being determined by the user. | |
puts "How many numbers from the sequence would you like to see?" | |
a = gets.chomp.to_i | |
def fib(n) | |
return n if (0..1).include? n | |
fib(n-1) + fib(n-2) if n > 1 | |
end | |
a.times do |i| |
array = ["Ruby", "Pascal", "Smalltalk", "io"] | |
# And then we want to return the value at Index 1: | |
array[1] | |
# vs. | |
puts array[1] |