Gestionnaire de fichiers - Editer - /opt/cpanel/ea-ruby24/root/usr/share/ri/system/syntax/page-miscellaneous_rdoc.ri
Arrière
U:RDoc::TopLevel[ i I"syntax/miscellaneous.rdoc:EFcRDoc::Parser::Simpleo:RDoc::Markup::Document:@parts[KS:RDoc::Markup::Heading: leveli: textI"Miscellaneous Syntax;To:RDoc::Markup::BlankLine S; ; i;I"Ending an Expression;T@ o:RDoc::Markup::Paragraph;[I"RRuby uses a newline as the end of an expression. When ending a line with an ;TI"Joperator, open parentheses, comma, etc. the expression will continue.;T@ o; ;[I"RYou can end an expression with a <code>;</code> (semicolon). Semicolons are ;TI"4most frequently used with <code>ruby -e</code>.;T@ S; ; i;I"Indentation;T@ o; ;[I"SRuby does not require any indentation. Typically, ruby programs are indented ;TI"two spaces.;T@ o; ;[I"RIf you run ruby with warnings enabled and have an indentation mis-match, you ;TI"will receive a warning.;T@ S; ; i;I"+alias+;T@ o; ;[I"TThe +alias+ keyword is most frequently used to alias methods. When aliasing a ;TI"5method, you can use either its name or a symbol:;T@ o:RDoc::Markup::Verbatim;[I"alias new_name old_name ;TI"alias :new_name :old_name ;T:@format0o; ;[I"KFor methods, Module#alias_method can often be used instead of +alias+.;T@ o; ;[I"8You can also use +alias+ to alias global variables:;T@ o;;[ I"$old = 0 ;TI" ;TI"alias $new $old ;TI" ;TI"p $new # prints 0 ;T;0o; ;[I"&You may use +alias+ in any scope.;T@ S; ; i;I"+undef+;T@ o; ;[I"TThe +undef+ keyword prevents the current class from responding to calls to the ;TI"named methods.;T@ o;;[I"undef my_method ;T;0o; ;[I"1You may use symbols instead of method names:;T@ o;;[I"undef :my_method ;T;0o; ;[I"$You may undef multiple methods:;T@ o;;[I"undef method1, method2 ;T;0o; ;[I"DYou may use +undef+ in any scope. See also Module#undef_method;T@ S; ; i;I"+defined?+;T@ o; ;[I"K+defined?+ is a keyword that returns a string describing its argument:;T@ o;;[I"1p defined?(UNDEFINED_CONSTANT) # prints nil ;TI"8p defined?(RUBY_VERSION) # prints "constant" ;TI"6p defined?(1 + 1) # prints "method" ;T;0o; ;[I"UYou don't need to use parenthesis with +defined?+, but they are recommended due ;TI"Lto the {low precedence}[rdoc-ref:syntax/precedence.rdoc] of +defined?+.;T@ o; ;[I"SFor example, if you wish to check if an instance variable exists and that the ;TI"instance variable is zero:;T@ o;;[I"=defined? @instance_variable && @instance_variable.zero? ;T;0o; ;[I"OThis returns <code>"expression"</code>, which is not what you want if the ;TI"&instance variable is not defined.;T@ o;;[I"@instance_variable = 1 ;TI">defined?(@instance_variable) && @instance_variable.zero? ;T;0o; ;[I"OAdding parentheses when checking if the instance variable is defined is a ;TI"Sbetter check. This correctly returns +nil+ when the instance variable is not ;TI"@defined and +false+ when the instance variable is not zero.;T@ o; ;[I"RUsing the specific reflection methods such as instance_variable_defined? for ;TI"Qinstance variables or const_defined? for constants is less error prone than ;TI"using +defined?+.;T@ S; ; i;I"+BEGIN+ and +END+;T@ o; ;[I"T+BEGIN+ defines a block that is run before any other code in the current file. ;TI"TIt is typically used in one-liners with <code>ruby -e</code>. Similarly +END+ ;TI"6defines a block that is run after any other code.;T@ o; ;[I"U+BEGIN+ must appear at top-level and +END+ will issue a warning when you use it ;TI"inside a method.;T@ o; ;[I"Here is an example:;T@ o;;[I" BEGIN { ;TI" count = 0 ;TI"} ;T;0o; ;[I"SYou must use <code>{</code> and <code>}</code> you may not use +do+ and +end+.;T@ o; ;[I"UHere is an example one-liner that adds numbers from standard input or any files ;TI"in the argument list:;T@ o;;[I"Kruby -ne 'BEGIN { count = 0 }; END { puts count }; count += gets.to_i';T;0: @file@:0@omit_headings_from_table_of_contents_below0
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0 |
proxy
|
phpinfo
|
Réglages