[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Question from newbie

Bill Guindon

2/18/2005 10:59:00 PM

On Sat, 19 Feb 2005 06:54:49 +0900, Panagiotis Karvounis
<pkarvou@gmail.com> wrote:
> Hi,I have just started using this great programming language and I am
> testing some features that I use with java.I am testing modules now.
>
> You may find my question very easy, but I hope you can help.
>
> When I run tmp.rb I get the error; "tmp.rb:3: uninitialized constant
> Pdate (NameError)"
>
> Why?
>

You need to give the module name before the class:

a = MyTools::Pdate.new(25,8,1983)
b = MyTools::Pdate.new(26,5,1986)

You can also 'include Comparable' in you class to make comparisons
easier. Here's a stripped down version of your code - with minor
edits just to show you 'case' and 'puts'.

module MyTools

class Pdate
include Comparable

attr_reader :day , :month , :year

def initialize(day,month,year)
@day=day
@month=month
@year=year
end


def <=> (other)
(@year <=> other.year) and (@month <=> other.month) and (@day
<=> other.day)
end
end

end

a = MyTools::Pdate.new(25,8,1986)
b = MyTools::Pdate.new(25,8,1986)

case
when a < b then puts "I am older"
when a > b then puts "I am younger"
else puts "We are the same age"
end

--
Bill Guindon (aka aGorilla)


1 Answer

Peter Jason

9/4/2009 11:05:00 PM

0


"La N" <nilita2004NOSPAM@yahoo.com> wrote in message
news:gI9om.42636$Db2.7551@edtnps83...
> Scotty wrote:
>> On Wed, 02 Sep 2009 17:20:58 GMT, "La N"
>> <nilita2004NOSPAM@yahoo.com>
>> wrote:
>>>
>>> What do you make of this? Is this guy's gripe legit?
>>> This has made
>>> the news over here.
>>>
>>> http://ca.news.yahoo.com/s/afp/090902/world/safrica_canada_refu...
>>>
>>
>> Having had a while to think about it, there is a story of
>> "targeted"
>> killings:
>>
>> SA has/had about 10,00 commercial/white farmers of which
>> approx. 2000
>> have been murdered over the last 14 years since the ANC
>> took over.
>> The murders are concentrated in areas disputed as a
>> result of the
>> relocation policies of the Apartheid government.
>>
>> Of course, they might just be soft targets in a crime
>> rivern country
>> but the stats/evidence is a bit overwhelming...
>>
>> President Zuma's signature song and dance routine at
>> election
>> campaigns is still "Bring me my machine gun", sung in
>> Zulu.
>>
>> SA also had to import corn for the first time this year,
>> connected?
>> Hard to tell...
>>
>> I don't normally read the SA papers but I've been
>> checking since you
>> asked. This in today's newspaper:
>> http://www.mg.co.za/article/2009-09-03-blacks-are-also-persecuted-says-cr...
>>
>> http://www.mg.co.za/article/2009-09-04-a-tale-of...
>> Rea Vaya is a new rapid transit system that started
>> Monday, I think,
>> and is being targeted by the Toyota mini buses with at
>> least one bus
>> being shot-up. Interesting read, with some shocking
>> spelling.. The
>> mini busses are a phenomenon... the worst drivers I've
>> ever seen,
>> aggressive, ignore red lights and apparently intimidate
>> their
>> passengers. They arose spontaneously as a result of
>> poor/non-existent
>> public transport. I think they are individually owned.
>
> I've heard from a couple of S. African friends on this.
> Among the comments one made is one of the *worst* things
> you could call a black South African is a "Nigerian" or
> "Somalian". But, I digress....
>
> This is very big news in Canada, and the latest is that
> the government wants to challenge the ruling:
> http://www.theglobeandmail.com/news/politics/ottawa-to-challenge-controversial-refugee-ruling/artic...
>
> Includes a photo of the refugee wearing ? a Corona Beer
> t-shirt?
>
> - nilita


Would you like to hear my Final Solution to the African
question?