Skip to main content

Posts

Showing posts with the label $

.any

@-Doing travel kata - any? vs empty? https://stackoverflow.com/questions/6245929/check-for-array-not-empty-any > [nil, 1].any? => true >> [nil, nil].any? => false - Using not in block def dont_give_me_five(start,end_)     (start..end_).count { | i | not i.to_s.include? '5' } end - Global $, Class @@ and Instance @ Variables. Never use global because it makes isolating bugs hard. http://www.rubyist.net/~slagell/ruby/globalvars.html https://stackoverflow.com/questions/12358084/whats-difference-between-and-in-a-module module A   @@a = 5 end class B   include A   puts @@a # => 5 end module A   @a = 5 end class B   include A   puts @a # => nil end -Regex cheatsheet http://www.rexegg.com/regex-quickstart.html -Array lessons c = [1,2,3,4]  => [1, 2, 3, 4] 2.4.1 :038 > c[0..3]  => [1, 2, 3, 4] 2.4.1 :039 > c[0...3] => [1, 2, 3] 2.4.1 :051 > c[0..-2] ...