#RubyTips içeren gönderiler

#RubyTips

X'te #RubyTips kullanan herkese açık gönderiler.

İlgili etiketler

  1. Jesus Castello@matugm
    Ruby Tip: Keep your class public interface as small as possible. Only expose methods that can be used by others. Everything else should be marked as private. #ruby #rubytips #OOP
    145
  2. Jesus Castello@matugm
    Ruby Tip: Ranges are not just for numbers! You can create time Ranges: + 60 You can also create string ranges: Array('a'..'z') And even INIFITE ranges: (1..Float::INFINITY).first(10) #ruby #rubytips #rubyguides
    158
  3. Schappi✓@Schappi
    Ever heard of String#inquiry in Rails? It turns strings into objects that respond to question methods, making code more readable. Instead of status == 'active', you can write . Super underrated! #RubyOnRails #RubyTips #CodeCleaner
    İndir
    00396
  4. Jesus Castello@matugm
    Ruby Tip: You can use [1].tap(&:pop) to remove the last item from an array & return the array itself instead of the removed item. #ruby #rubytips #rubyguides
    0010
  5. Jesus Castello@matugm
    [Ruby Tip] You can set the default value of a hash after creating it (either with {}, or to_h) Like this: h = {} h.default = 0 You can also set the default proc like this: h.default_proc = ->(h, k) { 123 } #ruby #rubyguides #rubytips
    015
  6. Jesus Castello@matugm
    Ruby Tip: You can convert an array into a hash using the Hash#[] method. Example: Hash[Array('a'..'z').zip(Array('a'..'z').rotate)] #ruby #rubyguides #rubytips
    2712
  7. Jakub Niewczas@j_niewczas
    Prevent throwing unknown keyword X (ArgumentError) when passing extra attrs to a method with keyword arguments: **_ #rubytips #ruby
    İndir
    201
  8. Jesus Castello@matugm
    Ruby Tip: Stop abusing inheritance! Don't use inheritance just to share a few methods between a group of classes. Only use inheritance for specialized versions of the base class. #ruby #rubytips #OOP
    0512
  9. Jesus Castello@matugm
    Ruby Tip: You can put a semicolon at the end of an expression in pry / irb to avoid the return value being printed on the screen. This helps when working with big strings or arrays! #ruby #rubytips
    1310
  10. Prathamesh Sonpatki✓@prathamesh2_
    #RubyTips String class provides handy methods `start_with?` and `end_with?` which basically do what they say. As argument they can take multiple strings and return true if any one of them matches with start or end of the string respectively. #Ruby
    İndir
    0524
  11. Jesus Castello@matugm
    Ruby Tip: You can use [1,2,3].tap(&:pop) to remove the last item from an array & return the array itself instead of the removed item. #ruby #rubytips #rubyguides
    0914
  12. Daha fazla gönderi göster