Feel the basic type and reference type easily with ruby

Launch Ruby on mac terminal

   irb

\ # When the value of the argument of the basic type method does not change

a=1
def method_primitive(a)
   a=2
end
method_primitive a #2
a #1 #Hasn't changed

\ # When the value of the argument of the reference type method changes

temp={}
temp[1]=1
def method_reference(temp)
	temp[1]=2
end
method_reference temp #2
temp[1] #2 #It has changed

Recommended Posts

Feel the basic type and reference type easily with ruby
Feel the basic type and reference type easily with ruby 2
Basic data type and reference type
With ruby ● × Game and Othello (basic review)
[Ruby] Basic code list. Keep the basics with examples
[Ruby] Method to easily get the receiver type .class
About Java basic data types and reference type memory
Ruby methods and classes (basic)
Find the address class and address type from the IP address with Java
[Java] Difference between assignment of basic type variable and assignment of reference type variable
The difference between programming with Ruby classes and programming without it
Basic data types and reference types (Java)
Programming with ruby (on the way)
Difference between primitive type and reference type
Java basic data types and reference types
Find the address class and address type from the IP address with Java [No. 2 decoction]
Determine the device type of smartphones, tablets, and PCs with Spring Mobile
[Firestore] Extract the collection with where condition in Ruby and delete the record
Do your best with gRPC with ruby ​​on the server and PHP on the client
Introduction to Ruby basic grammar with yakiniku
Memorandum (Ruby: Basic Grammar: Classes and Instances)
Convert JSON to TSV and TSV to JSON with Ruby
[Ruby] Difference between methods with and without self in the class. About class methods and instance methods.
[Ruby] Arguments with keywords and default values of arguments
I implemented Ruby with Ruby (and C) (I played with builtin)
Try to link Ruby and Java with Dapr
Publish the app made with ruby on rails
Manage the version of Ruby itself with rbenv
[Ruby] "Reference to object" and "Contents of variable"
[Competition Pro] Solve the knapsack problem with Ruby
Create jupyter notebook with Docker and run ruby
Easily monitor the indoor environment- (1) Motivation and concept-
Solving with Ruby and Crystal AtCoder ABC 129 D
Easily edit performance videos with ffmpeg using Ruby
[Ruby] Exclude duplicate elements with the uniq method.
Determine the current page with Ruby on Rails
Finding pi with the Monte Carlo method? (Ruby)
Java review ③ (Basic usage of arrays / reference type)
I checked the number of taxis with Ruby
[Ruby] Setting values ​​and memorandum for the table
[Beginner's point of view] I tried to solve the FizzBuzz problem "easily" with Ruby!