Skip to content

Instantly share code, notes, and snippets.

"string".gsub("g", "") # => "strin" (new value)
"string".gsub!("g", "") # => "strin" (modified original value)
hash = { person: "Ryan" }
hash.stringify_keys
# => { "person" => "Ryan" } you should see this result after hitting enter
def create_full_name(first, last)
"#{first} #{last}"
end
name_length = create_full_name("Ryan", "Kulp").length
def create_full_name(first, last)
"#{first} #{last}"
end
full_name = create_full_name("Ryan", "Kulp")
name_length = full_name.length
weekday? && not_monday || wednesday || friday
A && B || C || D
A && B # “and” => returns ‘true’ if A and B are both true
A || B # “or” => returns true if either A or B are true
if_true ? do_this : do_that
brew install yarn
rails new sample_app
cd sample_app
rails s
# visit http://localhost:3000 in your browser
rm -rf sample_app
@ryanckulp
ryanckulp / jp_morgan.rb
Created February 27, 2018 20:31
sanitizes JP morgan string variants to singular intention
str_a = 'j.p. morgan'
str_b = 'jp morgan chase'
str_a == str_b # => false
str = 'j.p. morgan'
str.downcase.gsub("j.p.", "jp").gsub("j.p", "jp").gsub("jp.", "jp").gsub("jp morgan", "jp morgan chase") # => "jp morgan chase"
def jp_morgan_chase?(str)