How to insert processing with any number of elements in iterative processing in Ruby

What to write in this article: pen_ballpoint:

~~ When I try to write a statement that determines whether a number is an integer in Ruby, I didn't come out of myself right away Output the contents as learning. ~~

About how to insert processing with an arbitrary number of elements in iterative processing Output as learning.

(Corrected because the processing and contents to be described are not suitable.: Bow :)

Divide the process according to whether it is a multiple of a specific number: decadeuous_tree:


pry(main)> test_num = 1
=> 1
pry(main)> test_num.to_f
=> 1.0
pry(main)> test_num.to_f.to_s.split('.')[1] == '0'
=> true

pry(main)> test_num2 = 1.05
=> 1.05
pry(main)> test_num2.to_f
=> 1.05
pry(main)> test_num2.to_f.to_s.split('.')[1] == '0'
=> false

(0..1000).to_a.each do |num|
  if num.fdiv(100).to_s.split('.')[1] == '0' && num != 0
    p 'Is a multiple of 100'
  end
end

Recommended Posts

How to insert processing with any number of elements in iterative processing in Ruby
How to start a subscript from an arbitrary number in Ruby iterative processing
Summary of how to select elements in Selenium
[Swift] How to get the number of elements in an array (super basic)
[How to insert a video in haml with Rails]
How to number (number) with html.erb
How to deal with different versions of rbenv and Ruby
How to iterate infinitely in Ruby
How to enclose any character with "~"
How to install Bootstrap in Ruby
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV
How to insert a video in Rails
How to determine the number of parallels
How to implement asynchronous processing in Outsystems
[Personal memo] How to interact with a random number generator in Java
How to execute with commands of normal development language in Docker development environment
How to build an environment for any version of Ruby using rbenv
How to change the maximum and maximum number of POST data in Spark
Iterative processing of Ruby using each method (find the sum from 1 to 10)
How to debug the processing in the Ruby on Rails model only on the console
[Java] [For beginners] How to insert elements directly in a 2D array
How to find the cause of the Ruby error
How to get the ID of a user authenticated with Firebase in Swift
How to insert all at once with MyBatis
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
How to build the simplest blockchain in Ruby
I checked the number of taxis with Ruby
How to implement Pagination in GraphQL (for ruby)
Offline real-time how to write Implementation example of the problem in E05 (ruby, C11)
[Java] How to get the key and value stored in Map by iterative processing
Find the greatest common divisor and least common multiple of any number of integers in Ruby
How to use git with the power of jgit in an environment without git commands
Summary of how to use the proxy set in IE when connecting with Java
How to embed JavaScript variables in HTML with Thymeleaf
How to make an image partially transparent in Processing
How to implement UICollectionView in Swift with code only
How to sort in ascending / descending order with SQLite
How to call functions in bulk with Java reflection
[Ruby on Rails] How to write enum in Japanese
How to switch Tomcat context.xml with WTP in Eclipse
[Ruby] The role of subscripts in learning elements in arrays
How to make LINE messaging function made with Ruby
How to use Z3 library in Scala with Eclipse
Converting TSV files to CSV files (with BOM) in Ruby
Organized how to interact with the JDK in stages
[Ruby On Rails] How to reset DB in Heroku
How to launch another command in a Ruby program
Addition of variables in iterative processing in a while statement
How to delete untagged images in bulk with Docker
How to use CommandLineRunner in Spring Batch of Spring Boot
How to use JDD library in Scala with Eclipse
How to handle TSV files and CSV files in Ruby
How to query Array in jsonb with Rails + postgres
How to judge the click of any area of the image
How to boot by environment with Spring Boot of Maven
Summary of how to implement default arguments in Java
How to resolve SSL_connect error in PayPal Ruby SDK
How to encode and calculate bitmaps of active user IDs with different dates in MaxCompute
Let's find out how to receive in Request Body with REST API of Spring Boot
How to use trained model of tensorflow2.0 with Kotlin / Java
Comparison of how to write Callback function (Java, JavaScript, Ruby)