How to write ruby if in one line Summary by beginner

ruby if in one line each method

If only true

if a>0
  puts a
end

If

puts a if a>0

for if else

if a>0
  puts a
else
  puts ""
end

If

puts a>o ? a:"0"

it seems like.

further if a>0 puts a else b=gets.chomp end If

a>o ? puts a:b=gets.chomp

it seems like.

As a memorandum for beginners ^^

Recommended Posts

How to write ruby if in one line Summary by beginner
[Ruby on Rails] How to write enum in Japanese
[Ruby] How to write blocks
How to iterate infinitely in Ruby
[Rails] How to write in Japanese
How to write easy-to-understand code [Summary 3]
How to increment the value of Map in one line in Java
How to get date data in Ruby
Summary of how to write annotation arguments
How to implement a slideshow using slick in Rails (one by one & multiple by one)
Summary of how to select elements in Selenium
[JavaFX] How to write Eclipse permissions in build.gradle
How to write an if statement to improve readability-java
JUnit 5: How to write test cases in enum
How to separate .scss by controller in Rails
How to write code that thinks object-oriented Ruby
[Ruby on Rails] How to install Bootstrap in Rails
How to build the simplest blockchain in Ruby
How to write Java String # getBytes in Kotlin?
Notes on how to write comments in English
How to implement Pagination in GraphQL (for ruby)
How to check if an instance variable is defined in a Ruby class
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
Javaer tries to summarize how to write properties in C #
[Ruby] How to use standard output in conditional branching
How to write offline real time Implementation example by ruby and C99 of F04
How to make LINE messaging function made with Ruby
Offline real-time how to write Implementation example of the problem in E05 (ruby, C11)
[Personal application work memo] How to display a bar graph and a line graph in one graph
How to launch another command in a Ruby program
How to check only one RadioButton check by default (Note)
How to write dockerfile
How to write docker-compose
How to write a date comparison search in Rails
How to write Mockito
How to handle TSV files and CSV files in Ruby
How to write an external reference key in FactoryBot
Summary of how to implement default arguments in Java
How to write migrationfile
How to write a core mod in Minecraft Forge 1.15.2
How to resolve SSL_connect error in PayPal Ruby SDK
How to specify character code and line feed code in JAXB
How to connect the strings in the List separated by commas
How to change a string in an array to a number in Ruby
Comparison of how to write Callback function (Java, JavaScript, Ruby)
How to set character code and line feed code in Eclipse
How to retrieve the hash value in an array in Ruby
How to select a specified date by code in FSCalendar
How to display a graph in Ruby on Rails (LazyHighChart)
[Rails5] japanMap link How to write parameters in js.erb file
[Rails] How to write user_id (foreign key) in strong parameter
Write DiscordBot to Spreadsheets Write in Ruby and run with Docker
[Ruby] How to batch convert strings in an array to numbers
How to write good code
Write class inheritance in Ruby
How to use JUnit (beginner)
How to use Ruby return
Bit Tetris (how to write)
How to write java comments
[Refactoring] How to write routing
[Ruby] How to comment out