This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_full_name(first, last) | |
"#{first} #{last}" | |
end | |
name_length = create_full_name("Ryan", "Kulp").length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_full_name(first, last) | |
"#{first} #{last}" | |
end | |
full_name = create_full_name("Ryan", "Kulp") | |
name_length = full_name.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weekday? && not_monday || wednesday || friday |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A && B || C || D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A && B # “and” => returns ‘true’ if A and B are both true | |
A || B # “or” => returns true if either A or B are true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if_true ? do_this : do_that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install yarn | |
rails new sample_app | |
cd sample_app | |
rails s | |
# visit http://localhost:3000 in your browser | |
rm -rf sample_app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
def date_night? | |
Date.today.wday == 5 # friday | |
end | |
unless date_night? | |
puts "study hard!" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless 2 + 2 == 4 | |
puts "Incorrect!" | |
end |