⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (820 Bytes)
Bug #20442
ยป test.rb
k776 (Kieran Pilkington)
, 04/22/2024 06:05 AM
class
Mock1
@val
=
0
class
<<
self
def
inc
@val
+=
1
end
def
print
@val
end
end
end
puts
"Mock1"
puts
Mock1
.
print
Mock1
.
inc
puts
Mock1
.
print
puts
""
class
Mock2
@val
=
{}
class
<<
self
def
inc
@val
[
'a'
]
||=
0
@val
[
'a'
]
+=
1
end
def
print
@val
end
end
end
puts
"Mock2"
puts
Mock2
.
print
Mock2
.
inc
puts
Mock2
.
print
puts
""
class
Mock3
@val
=
Hash
.
new
(
0
)
class
<<
self
def
inc
@val
[
'a'
]
+=
1
end
def
print
@val
end
end
end
puts
"Mock3"
puts
Mock3
.
print
Mock3
.
inc
puts
Mock3
.
print
puts
""
class
Mock4
@val
=
Hash
.
new
(
Hash
.
new
(
0
))
class
<<
self
def
inc
@val
[
'a'
][
'a'
]
+=
1
end
def
print
@val
end
end
end
puts
"Mock4"
puts
Mock4
.
print
Mock4
.
inc
puts
Mock4
.
print
puts
""
(1-1/1)
Loading...