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
What command do you run if you want to discard all changes since your last commit? | |
git stash | |
What command do you use if you run git add and then want to revert it? | |
git reset | |
What command do you use if you run git commit and then want to revert it? | |
git checkout **previous commit id** | |
that other command that fixes detached head mode that I always have to google. |
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
Detailed Ruby Questions | |
When would you use a hash instead of an array? | |
An array would be used to store multiple values in an ordered list. A hash should be used when you | |
need to store key value pairs. For example, if you were to store a person's information, putting it in | |
an array would require that you remember the order that the information is stored in, and this could change | |
as the information is changed or updated. Using a hash, however would allow you to store information by named keys. | |
So, to access a person's phone number you could use person[:phone_number] instead of person[3]. | |
When would you use a symbol instead of a string? |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write modules which will be included in the classes below which will give | |
# intelligent and bipedal behavior. | |
# | |
# You may not write any methods in the existing classes, but you may write | |
# `include` statements in them. | |
module Speak | |
def say_name |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a series of methods which use the .any, .all, .map, .select, .reject, and | |
# .reduce methods in Enumerable. Each of your methods should be one line. | |
def has_even?(arr) | |
arr.any?(&:even?) | |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a class which wraps around an array, but only allows odd numbers | |
# to be stored in the array. | |
class OddArray | |
def initialize(numbers) | |
@array = numbers.select{|num| num % 2 == 1} | |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
#I somehow overlooked this challenge. Submitting now on 9-21 | |
class Goat | |
attr_reader :name | |
def initialize(name) |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write two classes which inherit from the Vehicle class below. You will also | |
# need to add a method to the Vehicle class during this challenge. | |
class Vehicle | |
def initialize(make, model) | |
@make = make | |
@model = model |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a method which accepts one parameter. The method should return true if | |
# the string passed to it is a palindrome. It should return false if the string | |
# is not a palindrome | |
def palindrome?(string) | |
string.downcase! | |
string = string.gsub(/\W/, '') |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write a method which accepts an array and returns a hash. Each item in the | |
# array will be a string, and the returned hash should have last names as keys | |
# and first names as values. | |
# WRITE YOUR CODE HERE. Name your method `names`. | |
def first_name(name) | |
array = name.to_s.split |
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
# Write two methods: | |
# | |
# * `first_name`: given a name in string, return the first name. | |
# * `last_name`: given a name in string, return the last name. | |
# WRITE YOUR CODE HERE. |