- What is the difference between a local variable, and an instance variable? local to local, and instance to where ever
- What is the datatype of
"DevPoint Labs"
? string - Assign the number
10
to the local variablen
. N = 10 - Assign your name to the local variable
name
. name = "justin" - What is an Array? a collection of data with a 0 based index
- Give an example of when you’d use an Array. when listing items
- What is a method? naming a set of instrucitons
- Name 3 iterator methods for an Array. each, sort, split
- Name 3 methods for a String. .chomp .reverse .upcase
- What datatype does
5 / 2
return? fixum - What is a Hash? key based index using {}
- Give an example of when you’d use a Hash. like an array but more specific
- What is a class? classes are blueprints for how objects are created
- True or False; A class is a constant. true
true
andfalse
are called what? boolean- Write 4 conditional operators.
- / + -
-
Create a method called bucket that returns an empty array. def bucket e = [ ] end
-
Name 6 ruby special keywords. (a keyword is a word that already has a special meaning) class, def, end, elsif, else, rescue
-
How would you convert a number into a string? num.to_s
-
How would you convert a string into a number? "4".to_i
-
What is class inheritance? relation between two classes. Humans < Society
-
What are modules used for? grouping together methods, classes and contants. googs
-
What is a gem? code in a package shipped and ready to expedite some mutha fucking code
-
Name 4 gems, and their purposes. sinarta - ruby in html - small apps rails - build fast apps quickly gosu - 2d and musical development. i wonder if we use clojure, and overtone with ruby pry - used for debugging. still need help with debugging
-
What are comments used for in programming? sudo code, and remembering what was written
-
In Ruby, only 2 things evaluate to
false
. What are they? false, 0 -
Write 2 comparison operators. || && and these the same as conditonal as well?
-
Write the code for “ if dave’s age is greater than or equal to 21” if daves_age >= 5 puts "drink more beer" end
-
Instantiate a
Car
class. c = Car.new -
What is a method chain? adding two or more methods
-
How would you capitalize and reverse a string then print it out to the console? "justin".capitalize.reverse
-
What is a method to add an object to an array?
-
How would you add an object to a hash?
-
What are 2 valid datatypes of keys for a hash?
-
What is a writer method? creating new file to write
-
What is a reader method? reads only from the beginning of the file
-
There are 4 types of variables. What are they? local, @instance, @@class, $global
-
What does the question mark at the end of a method in ruby mean?
-
What’s a common way to debug your code? using pry? honestly, I don't know.
-
How would you return the string
"two"
from this array?arr = ["one", "two", "three"]
arr[1] -
How would you return the string
"DevPoint"
from this hash?hsh = {:name => "DevPoint"}
-
What is the datatype for
:age
? symbol -
What is the datatype for
-36.98
? float -
What is the datatype for
[1, 2, 3]
? array -
What is the datatype for
"BOOM goes the dynamite"
? string -
What is the datatype for
123412
? fixum -
What is the datatype for
{:food => "burger"}
? sting interpolation -
What is the datatype for
false
? false -
What is the purpose of
nil
? 0 nothing. -
How would you print out the current date? Time.now
-
How would you print out just the current year without using a Fixnum? time.year?
-
What is String interpolation? allowing ruby code to appear within a string. #{1 + 2}
-
What is String concatenation? with you take two or more strings and add them together
-
What does OOP stand for? object oriented programming
-
What does instantiation mean? creating objects of different types.
-
What is the name of the method that is called every time an object is instantiated? in order to start using the object, it must first be initaizled, so instance variable
-
What are arguments? passing ruby code in ()
-
How do you pass an argument? with variables
-
Write a method called
eat
that has an argumentfood
with a default value of"cheese"
. request some help -
What is a loop? loops are used to execute the smae block of code for a specific number of times. googs
-
How long has ruby been around? 19 years
-
How are you doing on this quiz so far? mind spun
-
Is anyone else hungry? actually, I am. I was, just at micky d's. college budget for a 34 year older, though I do feel like going out and grabbing a beer
-
What are the pipe characters used for in a block? pass in a variable
-
What is the difference between single quote strings and double quote strings? nothing
-
Name some rules for naming a method? used to bunlde one or more repeatable statements. begin with lower case letters. should be defined before calling them. googs, just saying.
-
How can you tell if a method is an instance or class method? class methods are methods that are called on a class and instance methods are methods called on an instance of a class. googs
-
In an instance method, what is
self
? self is whatever the instance method is in -
How do you add a dependency to a file?
-
I have a text file called
names.txt
. Each name is on it's own line. How would you print all the names in the file? -
When a method defines an argument that has a asterisk in front of a variable name, what is that asterisk referred to? e.g.
def thing(*stuff)
-
When a method defines an argument that has an ampersand in front of a variable name, what is that ampersand and variable name collectivly called? e.g.
def thing(&stuff)
-
What is it called when you see the
do
andend
keywords together? block -
What does DRY stand for? dont repeat yourself
-
What does DSL stand for? domain specfic language
-
This question left blank intentionally. why?
-
What does MRI stand for? matz's ruby interper
-
What is the difference between JRuby and MRI? they seem comparabe, though one might be faster than the other.
-
What would you use RubyMotion for? quickly lets one develop and test ios, and osx apps for iphone
-
Does your head hurt? no, but my head is spinning.
3- You can't use a capital letter for a variable name.
8- split is not a method on array
16- those are math operators, not conditional operators
27- 0 returns true in ruby. false and nil are what return false
33- << or push or assigning a value to an index are 3 ways to do this
34- assign a value to the key like hash[:name] = "Jeremy"
35- string and symbols
36- a method to write a value to an attribute
37- a method to read a value from an attribute
39- this method will return a boolean
42- hsh[:name]
48- string interpolation isn't a datatype. The answer is hash
52- It would be
Time.now.year
57- the name of the method is
initialize
60-
def eat(food="cheese"); end
66- there is a difference, look at string interpolation