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
--- question: how self refers to different objects depending on where it is in a Ruby program --- | |
Self refers to different objects by allowing you to access the class self is called upon. If you were to have a self.method inside a class named 'Person' instead of having to write Person.method, you can use self to call Person. Self calls its parent class if its inside a method and prints the methods class name. If self is called outside of a method in the same class, it will print the class, although it will give it an object value aswell. |
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
1 | Kiefer Johnson | Kiefer136@hotmail.com | |
---|---|---|---|
2 | ben byer | ben@.com | |
3 | ryan goodbrew | ryan@.com | |
4 | Steve Henderson | hevets@mail.com | |
5 | Don Burks | Don@lighthouselabs.ca | |
6 | Khurram Virani | kvirani@lighthouselabs.ca | |
7 | Dominos Pizza | dpiza@mails.co |
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_relative "./animalmodule" | |
class Animal | |
attr_reader :breath_air | |
attr_reader :num_legs | |
def initialize | |
@breath_air = true | |
@num_legs = 0 |
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
jpeg 1 2944429 | |
deb 4 15856384 | |
mp4 2 174921790 | |
zip 2 5736305 | |
pdf 1 194097 | |
rb 3 749 | |
js 1 97244 | |
rpm 1 4256 | |
jpg 1 8184 | |
mp3 1 5113626 |
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
def count_letters(string) | |
letters = Hash.new(0) | |
string_split = string.split('') | |
for x in string_split do | |
if x != ' ' | |
letters[x] += 1 | |
end | |
end | |
letters | |
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
[1] pry(main)> 5 + 10 | |
=> 15 | |
[2] pry(main)> REPL | |
NameError: uninitialized constant REPL | |
from (pry):2:in `__pry__' | |
[3] pry(main)> def say_hi(name) | |
[3] pry(main)* def say_hi(Josh) | |
[3] pry(main)* | |
[3] pry(main)> def say_hi(name) | |
[3] pry(main)* "hi #{name}" |