Sha256: 3dca34d5eef1ceb2da662a888ba298be2ba2c31bec42071215237bc69b49b080

Contents?: true

Size: 399 Bytes

Versions: 2

Compression:

Stored size: 399 Bytes

Contents

unless (RUBY_VERSION[0,3] == '1.9')

  class String

    # Iterates through each character. This is a little faster than
    # using #chars b/c it does not create the intermediate array.
    #
    #    a = ''
    #   "HELLO".each_character{ |c| a << #{c.downcase} }
    #    a  #=> 'hello'

    def each_char  # :yield:
      size.times do |i|
        yield(self[i,1])
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.4.2 lib/core/facets/string/each_char.rb
facets-2.4.3 lib/core/facets/string/each_char.rb