true is a logical quantity meaning true; the only representative of the class TrueClass;
false - a logical value meaning false; the only representative of the class FalseClass;
numbers — representatives of the Numeric class, which contains fractional (Float) and integer (Integer) subclasses;
strings — representatives of the String class;
nil— “nothing”; The only representative of the class NilClass.
Moreover, if you write 123_456 underscore will be ignored, this is done for the convenience of writing large numbers.
Large numbers, underscores, are also ignored.
0 for octal, 0x for hex, 0b for binary
+ "Addition"
- “subtraction”
* Multiplication
/ "Division"
** “exponentiation”
% "remainder of the division"
puts 5-3
puts 6/8
puts 6.0 / 8
puts 8 * 7
puts ((2000/10) - (4 * 5) + (2 ** 3)) * 3
\ n - go to next line
\ t - tab
"" String "+" string "" - sticks two lines.
““ String ”* n” - repeats the string nth number times.
“String” [position] ”, or“ string ”[position] .chr” —Returns the ASCII code of the character at the specified line position (counting starts from zero)
"" String "[0..3]" - Returns a substring enclosed in the specified range (counting the ends)
"String" [0,3] "- Returns a substring starting from the specified position and having the specified length
““ String ”.capitalize” —Replaces the first character of the string (if it is a letter of the Latin alphabet) with the capital
““ String ”.chop” —Delete the last character of the string (two characters if they are "\ r \ n")
"" String ".delete ('ea')" - Removes the specified characters from the string, the range of characters can be specified
"" String ".index (" cd ")", or "" string ".index (" cd ", 3)"; - Defines the position number from which the specified substring starts; You can specify the position number from which the search starts.
““ String ”.length”, or ““ string ”.size” —Define the length of the string (in bytes)
““ String ”.ljust (8)”, ““ string ”.rjust (8)”, ““ string ”.center (8)” - Complete the string with spaces to the specified width, aligning respectively with the left edge, right edge or centered
““ String ”.reverse” —Returns a string containing characters in reverse order
““ String ”.strip” —Drinks spaces at the beginning and end of a line
"" String ".squeeze", "" string ".squeeze ('* -')" - Leaves only one repeating character in the group; It is allowed to set the list of characters to which this action applies.
"" String ".tr ('25 ',' 47 ')" - Replaces all found occurrences of characters with the specified
puts "Koro" + "vkin" # Korovkin
puts "12345678" .size # 8
Source: https://habr.com/ru/post/11007/
All Articles