This file contains 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
AllCops: | |
DisabledByDefault: false | |
#################### Lint ################################ | |
Lint/AmbiguousOperator: | |
Description: >- | |
Checks for ambiguous operators in the first argument of a | |
method invocation without parentheses. | |
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args' |
This file contains 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
#Fibonacci Numbers | |
starting = -1 | |
following = 1 | |
ending = starting + following | |
20.times do | |
puts ending | |
starting = following | |
following = ending | |
ending = starting + following |
This file contains 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 Person | |
attr_reader :age, :job, :mood | |
def initialize | |
@age = 26 | |
@job = "sales" | |
@mood = "unexcited" | |
end | |
end |
This file contains 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 Person | |
def age(setAge) | |
@age = setAge | |
end | |
def job(occupation) | |
@job = occupation | |
end | |
def mood(setMood) |
This file contains 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 Calculator | |
def multiply(number1, number2) | |
number1 * number2 | |
end | |
def add(number1, number2) | |
number1 + number2 | |
end | |
def subtract(number1, number2) | |
number1 - number2 |
This file contains 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 Car | |
def new_car | |
return empty_array | |
end | |
def door | |
return "a door," | |
end | |
def engine | |
return "an engine," |
This file contains 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 Player | |
def score | |
puts "Goal!" | |
end | |
def block | |
puts "The keeper blocks it!" | |
end | |
end |
This file contains 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 Player | |
end | |
messi = Player.new | |
puts messi.class | |
class Fruit | |
This file contains 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
capitals = {"New Mexico" => "Santa Fe", "New York" => "Albany", "California" => "Sacramento", "Washington" => "Olympia", "Missouri" => "Jefferson City"} | |
puts "Pick a state, any state" | |
puts "Ok, only pick from one of the following 5 states" | |
puts "New Mexico" | |
puts "New York" | |
puts "California" | |
puts "Washington" | |
puts "Missouri" |
This file contains 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
#it works! you can hold arrays inside other arrays like so | |
x = [1,2,3,4,["What", "cat"]] | |
puts x | |
#This works as well - the first array holds the second array and the second array holds the third | |
x = [1,2,3,4, ["What", "cat", [1,2,3]]] | |
puts x |
NewerOlder