Skip to content

Instantly share code, notes, and snippets.

@GeekEast
Last active November 20, 2020 00:23
Show Gist options
  • Save GeekEast/5dc3d9ebfcd35f5cd912458c3ee5c93b to your computer and use it in GitHub Desktop.
Save GeekEast/5dc3d9ebfcd35f5cd912458c3ee5c93b to your computer and use it in GitHub Desktop.
Ruby: Knowledge Base

Ruby

Inspect

stock = StockQuote::Stock.quote("fb")
stock.inspect

Nil or?

a = nil
b = []
c = ""

a.blank? #=> true
b.blank? #=> true
c.blank? #=> true

d = "1"
e = ["1"]

d.blank? #=> false
e.blank? #=> false

Hash

  • ugly
:locals => { :label => "About", :path => "about" }
  • the same
locals: { label: "Home", path: "" }

require, include, extend and load

  • include: include method from module as instance method
  • extend: include method from module as static method
  • require: load libraries only once
  • load: load lobraries, may load many times.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment