Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ruby offer an equivalent of Perl's use strict? [closed]

Tags:

ruby

perl

I mean, there is no my in Ruby. I found use strict in Perl to provide very good anti-typo protection.

like image 663
user1134991 Avatar asked Dec 20 '12 12:12

user1134991


1 Answers

The strict pragma does three things in Perl. Two of the items are to
forbid the use of symbolic references and "barewords." Ruby doesn't
support these features, so it's not an issue.

The other feature of the strict pragma is to avoid creating random
global variables every time one is mentioned. In Ruby, globals look
different from other variables (the leading $), so this is not really
a problem. Local variables need to be assigned to before use, since
that's Ruby's method of declaration. That solves the same problem
the strict pragma handles for Perl.

Source: https://groups.google.com/forum/?fromgroups#!topic/ruby-talk-google/PiRnWplvGDw

like image 128
Azodious Avatar answered Nov 07 '22 09:11

Azodious