In general pass-by-value is just creating a copy of a value and passing it to a function. You can kinda "simulate" this behavior by using the Object#dup method.
Object#dup
h = {} def fun(value) puts value.object_id end fun(h) # => 47450799554260 fun(h.dup) # => 47450799938380
Just keep in mind that dup is just a shallow copy.
dup
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In general pass-by-value is just creating a copy of a value and passing it to a function.
You can kinda "simulate" this behavior by using the
Object#dup
method.Just keep in mind that
dup
is just a shallow copy.