Note

Even or odd

puts "Put numbers"
n = gets.to_i

if n.even?
 puts "Is an even number"
else n.odd?
  puts "Is odd"
end  

to_i to_s

gets is saved as a string. To convert to a number → gets.to_i

each_with_index

fruits=["Apple","melon","Strawberry"]

fruits.each_with_index do |fruit, i|
puts “#{i+1}The second element is#{fruit}is. ”
end
【result】
The first element is the apple.
The second element is the melon.
The third element is strawberries.

Change branches while inheriting uncommitted changes

http://vatscy.github.io/blog/2014/03/30/git-branch-stash/

Recommended Posts

Note
Note
[Note] Dockerfile
StringBuilder Note
Note: Installing SDKMAN
Rails Credentials Note
[Note] About nil
[Note] SQLite related
Firebase Authentication Note
[Note] Rails error list
[Java] Internal Iterator Note
[Note] Methods ending with?
Spring Cloud Netflix Note
Note: Ubuntu installation location
Java JUnit brief note
[java] Java SE 8 Silver Note
Android 8.0 --Wi-Fi Aware Note
[Note] Java: String search
[Note] Java: String survey
[Note] Rails3 routing confirmation
My Study Note (Java)
java: Add date [Note]
# 3 [Note] do ~ while statement