ruby memorandum (basic edition)

1.First of all

It is a memorandum for myself. It seems to look back when I forget it, and I plan to add it as needed.

2. Memorandum main subject

2.1 There are types in Ruby, and typical ones are string type (String) and integer type (Integer).

If the types are not unified, an error will occur.

to_s method… Convert from integer type to string type Example) puts "Sam's age is" + 27.to_s + ""

to_i method… Convert from character string type to integer type) Example) puts 100 + "200" .to_i

2.2 Method of string type object

puts "***".length(String length)
puts "***".reverse
puts "********".include?("***")(Is it included)

2.3 Added code for variable expansion

"#{variable}"
puts "#{name}Weight#{weight}kg"← Example

Variable expansion works only when enclosed in double quotes, When enclosed in single quotation marks, it is recognized as a character string rather than a variable.

Recommended Posts

ruby memorandum (basic edition)
Ruby on Rails Basic Memorandum
Memorandum (Ruby: Basic grammar: Iterative processing)
Ruby basic terms
[Ruby] Method memorandum
Pedometer (Ruby edition)
Memorandum (Ruby: Basic Grammar: Classes and Instances)
Safe numbers (ruby edition)
Ruby learning points (basic)
ruby basic syntax memo
Q. Elevator (Ruby edition)
Basic methods of Ruby hashes
Basic methods of Ruby arrays
Ruby on Rails basic learning ①
[Ruby] List of basic commands
Offline environment construction Ruby edition
Ruby methods and classes (basic)
Review of Ruby basic grammar
Basic knowledge of Ruby on Rails
memorandum
Ruby memorandum (acquisition of key value)
memorandum
With ruby ● × Game and Othello (basic review)
Dharma doll drop of characters (ruby edition)
Ruby on Rails installation method [Mac edition]
Basic cheat sheet by language (Ruby, PHP)
[Problem] Weather on consecutive holidays (Ruby edition)