Ruby/Zmienne globalne: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Szymon wro (dyskusja | edycje)
Szymon wro (dyskusja | edycje)
Linia 33:
|-
| $!
| informacja o ostatnim błędzie
| latest error message
|-
| $@
| położenie błędu
| location of error
|-
| $_
| ostatni łańcuch przeczytany przez <tt>gets</tt>
| string last read by gets
|-
| $.
| linenumer numberlinii lastprzeczytany readostatnio byprzez interpreter
|-
| $&
| ostatni łańcuch dopasowany przez wyrażenie regularne
| string last matched by regexp
|-
| $~
| ostatnie dopasowanie do wyrażanie regularnego, jako tablica podwyrażeń
| the last regexp match, as an array of subexpressions
|-
| $n
| then-te nthpodwyrażenie subexpressionw in the lastostatnim <tt>match</tt> (same as $~[n])
|-
| $=
| flaga niewrażliwości na duże/małe litery
| case-insensitivity flag
|-
| $/
| separator danych wejściowych
| input record separator
|-
| $\
| separator danych wyjściowych
| output record separator
|-
|$0
| nazwa bieżącego skryptu Rubiego
| the name of the ruby script file
|-
|$*
| argumenty z linii poleceń
| the command line arguments
|-
|$$
| identyfikator procesu interpretera
| interpreter's process ID
|-
|$?
| exit status ofwyjściowy lastostatniego executedwykonanego childprocesu processpotomka
|}
 
W powyższym <tt>$_</tt> i <tt>$~</tt> mają zasięg lokalny. Ich nazwy sugerują, że powinny być globalne, ale są one bardzo wygodne w ten sposób, a także są pewne historyczne powody używania tych nazw.
In the above, $_ and $~ have local scope. Their names suggest they should be global, but they are much more useful this way, and there are historical reasons for using these names.
<noinclude>
{{ProstaNawigacja|spis=Ruby|poprzart=Ruby/Zmienne|poprz=Zmienne|nastart=Ruby/Zmienne instancji|nast=ZMienne instancji}}