Is it possible to convert a range to a string? The idea is to make alpha = ("abcdefg..." etc). I want to do:
alpha.scan(/./) do |letters|
puts "I have five vowels", if letters.include?("a", "e", "i", "o, "u")
end
Method 1:
alpha = ("a".."z").to_s # Still returns a range
Method 2:
alpha = *("a".."z").to_s # Same; returns a range
Yes, try:
("a".."z").to_a.join # => => "abcdefghijklmnopqrstuvwxyz"
to_a.join the elements of the array.Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With