require 'with_else'

f = proc {puts "not breaking!"}

ar = 5.times.with_object([]) {|_, i| i << rand(5)}
ar.each.with_else(f) do |i|
  puts i
  break if i == 4
end

 

require 'with_else'

class String
  def not_include?(st)
    f = proc {self}
    l = st.size
    (size - l + 1).times.with_else(f) do |i|
      break false if self[i, l] == st
    end
  end
end

p "mijbdtoloov".not_include?("Ruby")
p "nice Ruby!".not_include?("Ruby")