Ruby

../../../_images/rben.png

catch throw

def run
x = rand(10000)
  if x == 86
    puts Time.now
    throw :end
  end
end

catch(:end) do
  10000.times { run }
end

load

require ‘’

load ‘’

require_relative ‘’

method

“a”.methods.grep /case/

regx

.scan

.gsub

=~

class

class Digit
end

class RandomNumer < Digit
        attr_accessor :numbers
          def initialize
            (1..10000).to_a.sample(10).sort
          end
end

sort

%w{ i like ruby 1 22 }.sort_by(&:length)

%w{ i like ruby 1 22 }.sort {|a,b| a.length <=> b.length}

%w{ i like ruby 1 22 }.sort_by {|str| -str.length }

h.sort_by(&:last)

events.sort_by {|event| [event.attends]}

line.each_with_object({}) {|a,b| b[a.capitialize] += 1}