Sha256: 8cf803a263493f0485395f99f7bc941cb2d9d25406fbb597c8e82609f07b1e86
Contents?: true
Size: 519 Bytes
Versions: 8
Compression:
Stored size: 519 Bytes
Contents
#! /usr/bin/env ruby # coding: utf-8 class String # Return the first index that meet mismatch between self and other String. # Return nil if self == other. # # Note that this method may return an index more than self.size. # e.g., "abc".mismatch( "abcd" ) #=> 3 def mismatch( other ) ary1 = self.split( // ) ary2 = other.split( // ) index = nil [ ary1.size, ary2.size ].max.times do |i| if ( ary1[i] != ary2[i] ) index = i break end end index end end
Version data entries
8 entries across 8 versions & 1 rubygems