From: Morton Goldberg Date: 2007-05-22T02:05:42+09:00 Subject: Re: Emergency help is needed On May 20, 2007, at 2:25 PM, anoosh wrote: > Hi all > I have 2 questions? > 1)What are the meaning of symbols(:var) and Instance variables(@x) > Ruby?(I know Java and C.If it is possible for you tell me the > synonyms in these languages,please) > > 2)How can I define my own exception handling in Ruby? That's really three questions, but who's counting? :) 1a. There is nothing like Ruby symbols in Java or C. Perhaps the best way for you to think about symbols is as objects that can serve as unique identifiers. Their main advantage (over strings) is very quick equality comparison. This makes them good hash keys. They are never garbage collected, which means you probably shouldn't use them in a situation where you are making a lot of objects for temporary use. 1b. Instance variables are pretty much equivalent to the field members of a Java class. 2. I hope you mean "how do I handle exceptions in Ruby?" The Ruby equivalent of Java's try { ... } catch( e) { ... } finally { ... } is begin ... rescue => e ... ensure ... end You will really have to read up on this to use it effectively, but knowing the keywords will allow you to Google for further help. Regards, Morton