I answered my own question. Forgot to initialize count = 0
I have a bunch of sentences in a paragraph.
a = "Hello there. this is the best class. but does not offer anything."
as an example.- To figure out if the first letter is capitalized, my thought is to
.split
the string so thata_sentence = a.split(".")
- I know I can
"hello world".capitalize!
so that if it wasnil
it means to me that it was already capitalized EDIT - Now I can use array method to go through value and use '
.capitalize!
- And I know I can check if something is
.strip.capitalize!.nil?
But I can't seem to output how many were capitalized.
EDIT
a_sentence.each do |sentence|
if (sentence.strip.capitalize!.nil?)
count += 1
puts "#{count} capitalized"
end
end
It outputs:
1 capitalized
Thanks for all your help. I'll stick with the above code I can understand within the framework I only know in Ruby. :)