[Wtr-general] Global Variables
Paul Carvalho
tester.paul at gmail.com
Fri Sep 1 18:30:10 EDT 2006
Is it called "Duck Typing" when Ruby figures out the variables as it goes
along?
That totally rocks. I only declare things as I need them in my scripts, and
if my tests didn't run sequentially I would be totally screwed. =)
On 01/09/06, Chris McMahon <christopher.mcmahon at gmail.com> wrote:
>
>
> Perl forces you to understand scope of variables fairly early (unless you
> write bad Perl using package variables, not lexical variables, and don't use
> warnings and don't use strictures, in which case you can ignore everything
> that follows): unless you declare variables' scope the first time the
> variable is used, the compiler gives you a warning. Variables declared
> within a routine with "my $var" are available only to that routine;
> variables declared outside routines with "my $var" are available to all
> subroutines declared in that scope.
>
> Global variables are designated by "our", not "my". "our $var" is
> available to all routines in the program.
>
> Managing this sometimes gets tricky. One of the most popular Perl FAQs of
> all time is "Coping with Scoping":
> http://perl.plover.com/FAQs/Namespaces.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060901/8f0c9b75/attachment-0001.html
More information about the Wtr-general
mailing list