Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A PR Has Been Submitted

A PR Has Been Submitted

Have you ever submitted a PR and it just comes back to you in 5 minutes? Maybe you should have reviewed your own PR first. Here's some tips on making your PR better

Paulo Ancheta

October 10, 2017

Transcript

34 slides
  1. # test.rb puts @car puts car $ ruby test.rb NameError:

    undefined local variable or method `car` for main:Object
  2. # test.rb puts “#{@car} #{car}” $ ruby test.rb NameError: undefined

    local variable or method `car` for main:Object
  3. # test.rb puts “This car is #{@car.capitalize}” $ ruby test.rb

    NoMethodError: undefined method `capitalize’ for nil:NilClass
  4. # test.rb hash = {a: {b: {c: {d: “ ”}}}}

    puts hash[:a][:b][:c][:d] $ ruby test.rb
  5. # test.rb hash = {a: {b: {c: {z: “ ”}}}}

    puts hash[:a][:b][:c][:d] $ ruby test.rb # nil
  6. # test.rb hash = {a: {b: {z: {d: “ ”}}}}

    puts hash[:a][:b][:c][:d] $ ruby test.rb NoMethodError: undefined method `[]' for nil:NilClass
  7. # test.rb hash = {a: {b: {c: {d: “ ”}}}}

    puts hash.dig(:a, :b, :c, :d) $ ruby test.rb
  8. # test.rb hash = {a: {y: {c: {d: “ ”}}}}

    puts hash.dig(:a, :b, :c, :d) $ ruby test.rb # empty output
  9. hash = {a: {y: {c: {d: “ ”}}}} puts hash.fetch(:a)

    .fetch(:b) .fetch(:c) .fetch(:d) $ ruby test.rb KeyError: key not found: :b # test.rb
  10. $ bin/rails c irb(main):1:0> Account.first.update(name: “this is too long”) Account

    Load (0.4ms) SELECT `accounts`.* FROM `accounts` ORDER BY `accounts`.`id` ASC LIMIT 1 (0.1ms) BEGIN Account Exists (0.2ms) SELECT 1 AS one FROM `accounts` WHERE (`accounts`.`token` = BINARY 'a6db14e97e1f9fe7' AND `accounts`.`id` != 1) LIMIT 1 (0.1ms) ROLLBACK false
  11. $ bin/rails c irb(main):1:0> Account.first.update!(name: “this is too long”) Account

    Load (0.4ms) SELECT `accounts`.* FROM `accounts` ORDER BY `accounts`.`id` ASC LIMIT 1 (0.1ms) BEGIN Account Exists (0.2ms) SELECT 1 AS one FROM `accounts` WHERE (`accounts`.`token` = BINARY 'a6db14e97e1f9fe7' AND `accounts`.`id` != 1) LIMIT 1 (0.1ms) ROLLBACK ActiveRecord::RecordInvalid: Validation failed: Name is too long (maximum is 20 characters) … … …

More Decks by Paulo Ancheta

Other Decks in Programming