⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (927 Bytes)
Feature #15251
» test_hash_keys_deduped.rb
chopraanmol1 (Anmol Chopra)
, 10/24/2018 01:03 PM
def
string_literal
+
"string_literal"
end
def
interpolated_string
underscore
=
-
"_"
"interpolated
#{
underscore
}
string"
end
def
string_times_3
"string times 3 "
*
3
end
def
string_times_1
"string times 1"
*
1
end
def
string_add
"string"
+
" "
+
"add"
end
def
appended_string
str
=
"string"
str
<<
" append"
str
end
def
string_arr
[
string_literal
,
string_times_1
,
string_times_3
,
interpolated_string
,
string_add
,
appended_string
]
end
def
fstring_arr
string_arr
.
each
{
|
str
|
-
str
}
end
def
print_hash_key_count
n
=
100
n
.
times
.
collect
{
string_arr
.
each
.
with_object
({}){
|
str
,
hsh
|
hsh
[
str
]
=
nil
}.
keys
}.
transpose
.
each
do
|
str_arrs
|
puts
"
#{
str_arrs
.
first
}
=>
#{
str_arrs
.
uniq
(
&
:__id__
).
count
}
"
end
end
print_hash_key_count
puts
"-+"
*
20
puts
"fstring"
puts
"-+"
*
20
fstring_arr
print_hash_key_count
puts
"-+"
*
20
puts
"fstring + GC"
puts
"-+"
*
20
fstring_arr
GC
.
start
print_hash_key_count
« Previous
1
2
Next »
(1-1/2)
Loading...