Skip to content

Commit 0fe85e1

Browse files
author
JoshEnplug
committed
V0.2 Attempt #3 ---> String to Characters
Attempted to pass in the result of string_split to the item_counts, but was unsuccessful. Comments/Questions are in lines 47-50.
1 parent c018c6c commit 0fe85e1

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

string.rb

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11

2-
def string_split(list)
3-
list.split("")
2+
def string_split(array)
3+
array.split("")
44
end
55

6-
print string_split("bob" "jane" "louis")
6+
print string_split("bob jane louis")
77

88
#puts "bob".split("")
99

1010
def item_counts(array)
11+
array = string_split(array)
1112
counts = {}
1213

1314
array.each do |item|
@@ -20,16 +21,30 @@ def item_counts(array)
2021
counts # This returns the "counts" hash
2122
end
2223

23-
puts item_counts([1,2,1,2,1])
24-
puts item_counts(["a","b","a","b","a","ZZZ"])
25-
puts item_counts([])
26-
puts item_counts(["hi", "hi", "hi"])
27-
puts item_counts([true, nil, "dinosaur"])
28-
puts item_counts(["a","a","A","A"])
24+
#puts item_counts([1,2,1,2,1])
25+
#puts item_counts(["a","b","a","b","a","ZZZ"])
26+
#puts item_counts([])
27+
#puts item_counts(["hi", "hi", "hi"])
28+
#puts item_counts([true, nil, "dinosaur"])
29+
#puts item_counts(["a","a","A","A"])
30+
31+
#def final_input(array)
32+
# final_input(string_split(array), item_counts(array))
33+
#end
34+
35+
36+
#print final_input("bobjaneus")
2937

3038
#p item_counts([1,2,1,2,1]) == {1 => 3, 2 => 2}
3139
#p item_counts(["a","b","a","b","a","ZZZ"]) == {"a" => 3, "b" => 2, "ZZZ" => 1}
3240
#p item_counts([]) == {}
3341
#p item_counts(["hi", "hi", "hi"]) == {"hi" => 3}
3442
#p item_counts([true, nil, "dinosaur"]) == {true => 1, nil => 1, "dinosaur" => 1}
3543
#p item_counts(["a","a","A","A"]) == {"a" => 2, "A" => 2}
44+
45+
46+
47+
# Questions #####
48+
# On line 11, I attempted to pass in the 'String_Split(array)' result as the definition of array'
49+
# On line 31-36, I tried passing it in as a new defined method like I had seen in Exercise_36 in the katas
50+
# Can you point me in the right direction again?

0 commit comments

Comments
 (0)