From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-02-03T07:55:57+09:00 Subject: Re: Variable types In article <3C5C3842.4010307@imperitek.com>, David Corbin wrote: >I know I'm new to ruby, but I feel obligated to share my dislike for >"special symbols" to indicate if a symbol is a member, local variable or >global variable. Perhaps I don't know enough to make such a comment, >and someone will show me my mistunderstanding. Well, it sounds like you understand how it works but you just don't like it ;-) Give it a few more weeks. Where you came from language-wise will influence this: * If you came from Perl you're probably thinking "An '@' should indicate an array not an instance variable and a '$' is for scalars..." * If you came from C/C++ you're wondering why we use any symbols at all. So, compared to Perl, Ruby uses a lot less sigils so they actually tend to stand out in your code more instead of being drowned out in the noise. Also, consider the alternatives: In Python in order to use an instance variable you have to use 'self': self.var In Ruby it's: @var The '@' is a lot shorter and to me it tends to stick out more in the code so that I can tell at a glance it's an instance var. (I'm not sure how Python does globals) In other languages you might have to declare a global like: global type var But how do you know the scope of 'var' when you see it later on in the code? The '$' prefix in Ruby is a nice way to tell 'at a glance' that var is global. So that's basically it: Ruby's way of indicating scope is concise and it's easy to read once you're used to it. Give it a few weeks, you'll get used to it and probably you'll start to appreciate it. Phil