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
"orange" == "red" # => false | |
1 + 3 == 4 # => true | |
12 - 1 != 10 # => 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
17 == 17 # => true | |
false != 12 # => true | |
1.2 == 3.4 # => false |
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
class Point | |
attr_reader :x | |
attr_reader :y | |
def initialize(x, y) | |
@x = x | |
@y = y | |
end | |
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
class Employee | |
attr_reader :id | |
attr_reader :name | |
def initialize(id, name) | |
@id = id | |
@name = name | |
end | |
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
# Find the book “Gödel, Escher, Bach” | |
repo = BookRepository.new | |
geb = repo.find(isbn: "978-0-14-028920-6") | |
geb_also = repo.find(isbn: "978-0-14-028920-6") | |
geb == geb_also # => false?! |
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
AMOUNT = 100_000_000 | |
num_tuesday_boy = 0 | |
num_tuesday_boy_and_two_boys = 0 | |
AMOUNT.times do | |
weekday1 = [:mon, :tue, :wed, :thu, :fri, :sat, :sun].sample | |
weekday2 = [:mon, :tue, :wed, :thu, :fri, :sat, :sun].sample | |
gender1 = [:boy, :girl].sample | |
gender2 = [:boy, :girl].sample |
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
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'rubocop', '~> 1.25' | |
gem 'benchmark-ips', '~> 2.9' | |
gem 'descriptive_statistics', '~> 2.5' |
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
Person = new Class {{ | |
firstName: :attr, | |
lastName: :attr, | |
fullName: function { | |
`${this.firstName} ${this.lastName}` | |
}, |
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
const input1 = [[3], [7, 4], [2, 4, 6], [8, 5, 9, 3]]; | |
// This should totes be part of JavaScript by default. | |
const maxBy = (arr, fn) => { | |
if (arr.length === 0) { | |
throw new Error("no!! just no"); | |
} | |
if (arr.length === 1) { | |
return arr[0]; |
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
################################################################################ | |
# Helper functions and constants | |
YES = [[]] | |
NO = [] | |
IF = | |
lambda do |val, if_yes, if_no| | |
val.each { return if_yes.call } | |
if_no.call |