⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (628 Bytes)
Bug #10209
» attributes.rb
crojas (Carlos Luis Rojas Aragonés)
, 09/06/2014 08:01 PM
require
'pp'
class
Attributes
attr_reader
:string
,
:array
,
:hash
def
initialize
@string
=
'value'
@array
=
[
1
,
2
,
3
,
4
]
@hash
=
{
name:
'Carlos'
,
age:
25
}
end
end
instance
=
Attributes
.
new
pp
'Original atributes:'
pp
'-------------------------'
pp
instance
.
string
pp
instance
.
array
pp
instance
.
hash
pp
'-------------------------'
# bang!!
# this should not afect the original atribute.
instance
.
string
.
gsub!
(
/.*/
,
''
)
instance
.
array
.
clear
instance
.
hash
.
clear
pp
'After Hacking attributes:'
pp
'-------------------------'
pp
instance
.
string
pp
instance
.
array
pp
instance
.
hash
pp
'-------------------------'
(1-1/1)
Loading...