I just began to learn ruby on rails. I'm doing a tutorial at the moment, but I'm also trying to understand the code that one of my collegue did. I have looked for the answers on internet but did not find any response which was answering my questions. So here are my questions :
On this code :
class Post
require 'date'
include Comparable
attr_accessor :post_number, :author, :date
def initialize
end
def <=> (another_post)
self.date <=> another_post.date
end
end
What does the method "<=>" means? Is it a copy of :post_number, :author and a change of :date? It seems that this method is not working anyway, but I'm just wondering the meaning of this method.
Second question : I found this code : a, b and c have proper value.
a = 0.1 * b if c?
Is this any different of :
if c?
a = 0.1 * b
end
Well, thank you for your answers and I hope that my questions are not too stupid. Regards, Bdloul