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
| 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
| 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
| 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
| 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
| 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
| hash = { person: "Ryan" } | |
| hash.stringify_keys | |
| # => { "person" => "Ryan" } you should see this result after hitting enter |
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
| "string".gsub("g", "") # => "strin" (new value) | |
| "string".gsub!("g", "") # => "strin" (modified original value) |
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 +(parameter_here) | |
| # logic here | |
| 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
| # Multi-line inner loop blocks | |
| collection.each do |parameter_name| | |
| # logic_here | |
| end | |
| # Single-line inner loop blocks | |
| collection.each { |parameter_name| logic_here } |