From: Dan Zwell Date: 2007-05-21T04:57:39+09:00 Subject: Re: Emergency help is needed 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? > > Symbols tend to be used like constants sometimes are in other languages. Take this line of java: jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); If ruby had this class with these methods, it would probably use symbols instead of constants: jSplitPane.setOrientation(:vertical_split) Symbols don't have scope--they are not variables. Symbols are unique, and they do not contain a value the same way that variables do. I have seen them compared to numbers--'4' is unique and its value cannot be changed. Also like numbers, you do not need to create them--you can just start referencing them. In C, symbols can be used like (instead of) enums--for constants whose value does not actually matter. Dan