Today I Learned

TIL, 2017-05-09

  • group_by–we can do things like this: names.group_by { |name| name[0] }
  • data.group_by { |number| number /20 }
  • Ruby Struct, you can get elements by index as well by name:
  • Structs don’t have native keyword argument support.
Person = Struct.new(:name, :age)
p = Person.new("fred", 26)
p[0]
  • The error that Ruby raises when it can’t find a method is NoMethodError.
  • cp -i for interactive mode, cp -r for copying recursively.
  • mv -i for interactive mode.
  • rm -r for recursive directory removal.
  • chmod 777 myfile. Number explanation:

This project is maintained by daryllxd