Skip to content

Instantly share code, notes, and snippets.

@elenawalom
Last active December 18, 2015 19:29
Show Gist options
  • Save elenawalom/5833554 to your computer and use it in GitHub Desktop.
Save elenawalom/5833554 to your computer and use it in GitHub Desktop.
Day 5 Notes
We need to know about:
variables, objects, types, and loops.
Variables are references to things that we create in our program. WE give them nice names so that code becomes readable.
12tmp = not variable
tmp12 = variable because variables have to start with letter
myVar = 2 is a variable
What is an object? Anything in RUBY. Everything is an object.
What are types of objects? And we assign those objects to our variables.
Array and hash are a collection of objects that you can iterate over by utilizing loops.
Loops: We use loops (which are concept/structures, just like a question) as a method to access objects within an array or hash or other types of objects.
Class is a way to store and access methods and variables.
Object is two things: data and methods.
type class
1 2 3 number FixNum
1.5 number Float
*Authors of Ruby came up with these notions (FixNum), (Float)
Class
Data Methods Objects
ga-flickr.rb contains methods
image.rb contains title, image, directlink and text (or 3 instance variables)
Image class = blank email
It has to, from, cc, and data inside
Everytime you write images.new that's the equivalent of clicking compose
Attribute accessor = anyone in outside world can change
Attribute reader = read only, don't change
If you print out an array full of hashes you see exactly what it looks like
How do you create a class with a method called 2S?
If I wanted to iterate over an array with people's names, how would I do it?
Difference b/t Ruby Shell and Bash Shell
Ruby shell meant for use with objects
Bash shell requires very little knowledge in order to start using it. Bash makes easy things easy and difficult things impossible.
Variables, hash dash and loops
variables
@x = 3
@x = lovepeacejoy
:hope
hash dash
What is the end experience? It's not the approach of how will I solve the problem but it's the approach of how will I know that the problem is solved?
Start with the most discrete problem. Discrete meaning one that doesn't have a lot of dependencies on others.
What is a method on an array that will give you a single item/element on an array? First.
TDD = test driven development
Constant variables are always capitalized (all caps locks)
Are constant variables instance variables as well?
jump -- umpjay
dance -- anceday
elephant -- elephantway
illusion -- illusionway
bridge -- idgebray
street -- eetstray
shirt -- irtshay
breathe -- eathebray
eye -- eyeway
yellow -- ellowyay
aj -- ajway
jackie -- ackiejay
apple -- appleway
hello world -- ellohay orldway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment