[Tfug] code won't compile
Glen Pfeiffer
glen at thepfeiffers.net
Mon Oct 8 20:26:57 MST 2007
On 10/08/2007 06:09 PM, Christopher Robbins wrote:
> We're missing a bigger issue here...
>
> You wrote the code in bash!
>
> If you want to get that code working, you need a higher-order,
> object-oriented (as the Woman is) language. Write it in something
> a bit sexier, like Java or Python. Ruby might be the more obvious
> choice here, women seem to prefer them over snakes or coffee.
>
> Refactor it, try it again.
#!/usr/bin/env ruby
class You
attr_accessor :sex
attr_accessor :looks
def initialize(sex, looks)
@sex = sex
@looks = looks
end
def to_s
@looks
end
end
class Me
attr_accessor :righthand
attr_accessor :alone
def initialize
@alone = "Boring!"
end
end
class Match
def good?(female, male)
if female.sex == 'Woman' and female.looks == 'HOT!!!'
puts female and male
else
puts male.alone
end
end
end
match = Match.new
you = You.new("Woman", "HOT!!!")
me = Me.new;
match.good?(you, me)
--
Glen
More information about the tfug
mailing list