Phrogz wrote:
class Person
attr_accessor :name
def initialize(name)
@name=name
end
def love(otherPerson)
puts self.name+" loves "+otherPerson.name+"\n"
end
endI=Person.new("Jen Switalski")
you=Person.new("a programmer")
while true
I.love(you)
end
Let's tighten that up a bit, and remove the non-rubyesque camel
casing.Person = Struct.new( :name ) do
def love( other )
puts "#{self.name} loves #{other.name}"
end
end
I = Person.new("Jen Switalski")
you = Person.new("Bob")
while true
I.love(you)
endDunno if that'll fit on the cake, but it gets closer.
Whenever I've seen anything like this done, it's always been done in C. Though I'm not suggesting we use C, I always thought the #include's added a little something extra. So, why not put a couple of require's at the top? Such as,
(require is the statement to include library functions/other modules, so you can re-use functionality)
require 'love'
require 'time'
jen = Person.new("Jen")
fiance = Person.new("Fiance")
us = [jen, fiance]
love = Love.new(jen, fiance)
while(Time.now < Death.parts(us))
jen.loves(fiance) unless love.conditional?
end
This creates a new 'love' object, taking Jen and Fiance as parameters (who are set up as 'constants') and loops while the current time is less than when Death parts the two of you, it says that Jen will love Fiance unless the love is conditional, which is funny because I put it in a conditional statement. It needs editing, but it's something for others to build on!
Michael
···
On Mar 21, 8:33 pm, p...@informatimago.com (Pascal J. Bourguignon) > wrote: