About eval in Ruby

About eval in Ruby

Background

On various sites, it was written as "a method to execute a character string given as an argument as a Ruby program", but I have a poor understanding, "Well then, isn't the usual character string Ruby?" I thought about it ... (completely stupid)

Explanation

input

Ruby


1-1
1+1
1*1
1/1
10+10
code

Ruby


puts eval gets
puts eval gets
puts eval gets
puts eval gets
eval "puts gets"
output

Ruby


0
2
1
1
10+10

Only this ... I didn't understand this (despair)

Recommended Posts

About eval in Ruby
About regular expressions in Ruby
[Super Introduction] About Symbols in Ruby
About Ruby symbols
About ruby ​​form
About Ruby Hashes
Class in Ruby
About Ruby arrays
About Ruby inheritance
About ruby block
About Ruby Hashes
Heavy in Ruby! ??
About Ruby Symbols
About Ruby variables
About Ruby methods
About Ruby Kernel Module
About Ruby error messages
About Ruby exception handling
About Ruby Hashes (continued)
[ruby] About here documents
About Ruby if statement
About Ruby instance methods
Output triangle in Ruby
[Ruby] About instance generation
About redirect_to in form_with
Variable type in ruby
About the [ruby] operator
Fast popcount in Ruby
Thinking about logic Ruby
About docker.credentials.errors.StoreErrorTraceback in wsl2
About regular expressions used in ruby sub method
About the difference between classes and instances in Ruby
ABC177 --solving E in Ruby
Validate JWT token in Ruby
Implemented XPath 1.0 parser in Ruby
Read design patterns in Ruby
About validation methods in JUnit
Write class inheritance in Ruby
Explanation about Ruby Range object
Update Ruby in Unicorn environment
Integer unified into Integer in Ruby 2.4
[Ruby] Exception handling in functions
Use ruby variables in javascript.
[Ruby on Rails] about has_secure_password
Multiplication in a Ruby array
About Ruby hashes and symbols
Ruby About various iterative processes
Birthday attack calculation in Ruby
Judgment of fractions in Ruby
About Ruby and object model
Find Roman numerals in Ruby
Try using gRPC in Ruby
About abstract classes in java
About Ruby classes and instances
[Ruby] Find numbers in arrays
NCk mod p in Ruby
Chinese Remainder Theorem in Ruby
Explanation about Ruby String object
I made an interpreter (compiler?) With about 80 lines in Ruby.
About the difference between "(double quotation)" and "single quotation" in Ruby
About the behavior of ruby Hash # ==