[Ruby] Summary of how to get values from standard input [Paiza skill check measures]

Get value from one line

#========================================
Put the gets method in the pattern 1 variable and output with puts
#========================================
n = gets
puts n


#========================================
Pattern 2 How to use stdin
#========================================
puts $stdin.gets

Get elements from multiple lines and output

Standard input 2 4 7

#========================================
pattern 1
#========================================


#========================================
Pattern 2
#========================================
puts $stdin.readlines 

readlines reads the multi-line value obtained by stdin as an "array". You can also put it in a variable with n = $ stdin.readlines and doputs n [0].

Recommended Posts

[Ruby] Summary of how to get values from standard input [Paiza skill check measures]
[ruby] How to receive values from standard input?
paiza skill check standard input / output summary [Java edition]
From terminal to Ruby (standard input / output)
[Java] How to get and output standard input
How to get the longest information from Twitter as of 12/12/2016
How to display 0 on the left side of the standard input value
[Ruby on Rails] "|| =" ← Summary of how to use this assignment operator
How to get and add data from Firebase Firestore in Ruby
Learning Ruby with AtCoder 11 How to receive frequently used standard input
[Swift] Summary of how to remove elements from an array (personal note)
[For Rails beginners] Summary of how to use RSpec (get an overview)
How to get date data in Ruby
[java] Summary of how to handle char
Summary of how to write annotation arguments
[IOS] How to get data from DynamoDB
[Java] [Maven3] Summary of how to use Maven3
Java: How to send values from Servlet to Servlet
Try to carry out paiza skill check
[Ruby on Rails] Rails tutorial Chapter 14 Summary of how to implement the status feed
How to get an arbitrary digit from a number of 2 or more digits! !!
Summary of how to select elements in Selenium
How to find the cause of the Ruby error
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
[java] Summary of how to handle character strings
Summary of how to create JSF self-made tags
[Swift] Template for receiving standard input of Paiza
How to get a heapdump from a Docker container
[Java] Summary of how to abbreviate lambda expressions
Summary of moss when updating from JMockit 1.4 to 1.30
How to get Class from Element in Java
How to get today's day of the week
How to display the result of form input
How to get SIMD optimization from HotSpot JavaVM
[Java] How to get the authority of the folder
Ruby standard input
[Java] How to get the URL of the transition source
[Ruby] How to use standard output in conditional branching
How to write Scala from the perspective of Java
Rails / Ruby: How to get HTML text for Mail
[Ruby] How to find the sum of each digit
[Java] How to get the maximum value of HashMap
How to output standard from an array with forEach
As of April 2018 How to get Java 8 on Mac
Summary of Java communication API (1) How to use Socket
[Android] How to get the setting language of the terminal
[Eclipse] Summary of environment settings * Updated from time to time
Summary of Java communication API (3) How to use SocketChannel
How to prevent editTextPreference of android PreferenceFragmentCompat from breaking
Summary of Java communication API (2) How to use HttpUrlConnection
[Rails] How to get the contents of strong parameters
Summary of how to implement default arguments in Java
[Ruby] How to get the tens place and the ones place
[Swift] How to get the document ID of Firebase
How to get jdk etc from oracle with cli
[Ruby On Rails] How to search and save the data of the parent table from the child table