⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (851 Bytes)
Feature #4893
» StringInit.rb
lazaridis.com (Lazaridis Ilias)
, 06/26/2011 04:54 PM
#!/usr/bin/env ruby
class
String
@@running_counter
=
0
def
initialize
(
val
)
@@running_counter
+=
1
end
def
self
.
running_counter
@@running_counter
end
end
puts
String
.
call_initialize
==
FALSE
String
.
call_initialize
=
TRUE
puts
String
.
call_initialize
==
TRUE
p
String
.
running_counter
oo_string
=
String
.
new
(
"The OO String 1"
)
p
String
.
running_counter
li_string
=
"The Literal String 2"
p
String
.
running_counter
oo_string
=
String
.
new
(
"The OO String 3"
)
p
String
.
running_counter
String
.
call_initialize
=
FALSE
puts
String
.
call_initialize
==
FALSE
li_string
=
"The Literal String 4"
p
String
.
running_counter
li_string
=
'The Literal String 5'
p
String
.
running_counter
String
.
call_initialize
=
TRUE
puts
String
.
call_initialize
==
TRUE
puts
"Print Literal"
p
String
.
running_counter
« Previous
1
2
3
4
5
6
…
13
Next »
(4-4/13)
Loading...