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 change a string in an array to a number in Ruby
How to deal with different versions of rbenv and Ruby
How to iterate infinitely in Ruby
How to enclose any character with "~"
[Ruby] How to use any? Method
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV
How to get date data in Ruby
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
[Ruby] Explanation for beginners of iterative processing with subscripts such as each_with_index!
How to build an environment for any version of Ruby using rbenv
How to find the total number of pages when paging in Java
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
[Ruby] Iterative processing
How to get the ID of a user authenticated with Firebase in Swift
How to insert all at once with MyBatis
How to use JQuery in js.erb of Rails6
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
Ruby Iterative Processing
[Ruby on Rails] How to install Bootstrap in Rails
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)
Find the greatest common divisor and least common multiple of any number of integers in Ruby
How to request by passing an array to the query with HTTP Client of Ruby
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
Count the number of occurrences of a string in Ruby
How to make batch processing with Rails + Heroku configuration
How to call functions in bulk with Java reflection
[Ruby] How to use standard output in conditional branching
[Ruby on Rails] How to write enum in Japanese
How to switch Tomcat context.xml with WTP in Eclipse
How to make LINE messaging function made with Ruby
[Ruby] How to find the sum of each digit
How to use Z3 library in Scala with Eclipse
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 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 deal with SQLite3 :: BusyException that occurs when uploading a large number of images using ActiveStorage in seeds.rb etc.