@alexpeattie
slides.com/alexpeattie/love
dd = Time.now + (wl == [] ? 1814400 : 1209600)
Loan.new(dd)
if wl == []
dd = Time.now + 1814400
else
dd = Time.now + 1209600
end
Loan.new(dd)
if waiting_list == []
due_date = Time.now + 1814400
else
due_date = Time.now + 1209600
end
Loan.new(due_date)
if waiting_list.empty?
due_date = Time.now + 1814400
else
due_date = Time.now + 1209600
end
Loan.new(due_date)
if waiting_list.empty?
# due date 3 weeks from now
due_date = Time.now + 1814400
else
# due date 2 weeks from now
due_date = Time.now + 1209600
end
Loan.new(due_date)
week = (7 * 24 * 60 * 60)
if waiting_list.empty?
due_date = Time.now + (3 * week)
else
due_date = Time.now + (2 * week)
end
Loan.new(due_date)
if waiting_list.empty?
due_date = weeks_from_now(3)
else
due_date = weeks_from_now(2)
end
Loan.new(due_date)
if waiting_list.empty?
due_date = weeks_from_now(3)
else
due_date = weeks_from_now(2)
end
Loan.new(due_date)
dd = Time.now + (wl == [] ? 1814400 : 1209600)
Loan.new(dd)
class Yogi
def cat_pose
imitate Cat.new
end
def cow_pose
imitate Cow.new
end
def cobra_pose
imitate Cobra.new
end
end
denise = Yogi.new
denise.cat_pose
class Yogi
%w(cat cow cobra).each do |animal|
define_method("#{animal}_pose") do
imitate Object.const_get(animal.capitalize).new
end
end
end
denise = Yogi.new
denise.cat_pose
class Yogi
def cat_pose
imitate Cat.new
end
def cow_pose
imitate Cow.new
end
def cobra_pose
imitate Cobra.new
end
end
denise = Yogi.new
denise.cat_pose
def is_something?(string)
1.upto(string.length) do |n|
return false if string[n - 1] != string[-n]
end
true
end
def is_something?(string)
string == string.reverse
end
def is_something?(string)
string == string.reverse
end
def is_something?(string)
1.upto(string.length) do |n|
return false if string[n - 1] != string[-n]
end
true
end
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
god yzal eht revo spmuj xof nworb kciuq ehT
But for 1 million runs with a 20,000 word string..
the difference is 2s
alex@peg.co
@alexpeattie
slides.com/alexpeattie/love