Discussion: minimal nntp client
Afficher un message
Vieux 14/03/2008, 06h05   #5
Gerry Ford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: minimal nntp client

Thomas Wieczorek wrote:
> On Thu, Mar 13, 2008 at 2:32 AM, Gerry Ford <wade@zaxfuuq.net> wrote:
>>
>> Q1) What is the ruby analog to the perl use of strict and warnings?
>>

>
> I am not really experienced in Perl, but as I understand it. strict
> enforces that you have to declare variables, so that when you mistype
> something an error occurrs. You get a NameError in Ruby when you use a
> variable which hasn't any value assigned:
>
> # irb
> # foo has a value
> foo = "Hello"
> puts foo # "Hello"
>
> # bar is not declared
> puts bar
>
> # NameError: undefined local variable or method `bar' for main:Object
> # from (irb):6
>
> As far as I know you can't turn warnings on from your code, but you
> can run Ruby with the "-w" option which shows warnings.

Thanks, Thomas. It sounds like ruby is already "strict" in the perl
sense. As for warnings, I'll enable them on the goocher, which is what
I call a dos command that I comment out at the end of a script: Thus

# perl client2.pl >text59.txt 2>text56.txt
__END__
becomes, in ruby, with warnings enabled:

# ruby -w client2.rb >text59.txt 2>text56.txt
__END__

Cheers.
--
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
 
Page generated in 0,04902 seconds with 9 queries