Hi,
Here's the 4th hint.
To check to see if a given element in an array is a lower value than the previous element, you'd do this:
a = [3, 2, 1]
puts a[2] < a[1] # true
With these hints, it should be possible to write a method that iterates backwards over an array and swaps each element with its previous element if the element is less than the previous element. If you do that iteration enough times, you will eventually have a sorted array. This is called a bubble sort in computer science.
Glenn
Sunday, July 19, 2009
Hint #3 for my_sort
Hi,
Here's the 3rd hint.
You can iterate backwards over an array with the following code:
def reverse_each(arr)
(arr.size - 1).downto(0) { |i| print arr[i] }
end
reverse_each([3, 2, 1]) # 123
One question about the code above: why did I write (arr.size - 1)?
Look for hint #4 later today.
Glenn
Here's the 3rd hint.
You can iterate backwards over an array with the following code:
def reverse_each(arr)
(arr.size - 1).downto(0) { |i| print arr[i] }
end
reverse_each([3, 2, 1]) # 123
One question about the code above: why did I write (arr.size - 1)?
Look for hint #4 later today.
Glenn
Friday, July 17, 2009
Hint #2 for the my_sort method
Here's the second hint:
Use the self object in your method.
The third hint will be tomorrow.
Glenn
Use the self object in your method.
The third hint will be tomorrow.
Glenn
Thursday, July 16, 2009
Hint #1 for the my_sort method assignment
Hi All,
Here's the first hint for the my_sort assignment.
To swap 2 elements in an array -- say the 3rd element and the 2nd element -- you'd do this:
a = [1, 2, 3]
a[2], a[1] = a[1], a[2]
puts a.inspect # [1, 3, 2]
Look for the 2nd hint tomorrow or Saturday.
Glenn
Here's the first hint for the my_sort assignment.
To swap 2 elements in an array -- say the 3rd element and the 2nd element -- you'd do this:
a = [1, 2, 3]
a[2], a[1] = a[1], a[2]
puts a.inspect # [1, 3, 2]
Look for the 2nd hint tomorrow or Saturday.
Glenn
Wednesday, July 15, 2009
Assignment for the July 20th class
Hi All,
The assignment for the July 20th class is to write a method to sort an array of numbers without using the array's out-of-the-box sort method.
The code should look like this:
class Array
   def my_sort
     ... your code goes here ...
   end
end
Look those some hints over the next few days.
Glenn
The assignment for the July 20th class is to write a method to sort an array of numbers without using the array's out-of-the-box sort method.
The code should look like this:
class Array
   def my_sort
     ... your code goes here ...
   end
end
Look those some hints over the next few days.
Glenn
Saturday, July 11, 2009
Hint #4
Hi,
Here's the 4th and last hint.
So far, we have:
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
a.each { |e| h[e] += 1 }
That gives us a hash with a key for each element in the original array, and value for each time that key appeared in the array.
To complete the assignment you need to do 5 things:
1) Find out what the maximum times an element appeared in the array using the values method on the hash, which returns an array.
2) Find out the highest value with the max method on that array.
3) Remove all of the key-value pairs in the hash that do not have a value equal to the highest value.
4) Use the keys method on the hash that's left.
5) So far, none of the code that I've shown has been in a method definition. So the last step would be to take what we have and write a method definition around it.
There's a couple of things that I've shown here that could be made more efficient and elegant. Take a minute to look at the code to see if you can come up with what they are.
See you on Monday!
Glenn
Here's the 4th and last hint.
So far, we have:
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
a.each { |e| h[e] += 1 }
That gives us a hash with a key for each element in the original array, and value for each time that key appeared in the array.
To complete the assignment you need to do 5 things:
1) Find out what the maximum times an element appeared in the array using the values method on the hash, which returns an array.
2) Find out the highest value with the max method on that array.
3) Remove all of the key-value pairs in the hash that do not have a value equal to the highest value.
4) Use the keys method on the hash that's left.
5) So far, none of the code that I've shown has been in a method definition. So the last step would be to take what we have and write a method definition around it.
There's a couple of things that I've shown here that could be made more efficient and elegant. Take a minute to look at the code to see if you can come up with what they are.
See you on Monday!
Glenn
Hint #3 for the mode assignment
Hi,
Here is the 3rd hint.
We've already created a hash, and used the each method to start the hash out with a key for each unique element of the hash, and we've already set the value for each key in the hash to be equal to 0.
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
puts h.inspect # {1 => 0, 2 => 0, 3 => 0}
Now, we are ready to count how many times each element in the array actually occurs.
a.each { |e| h[e] += 1 }
puts h.inspect # {1 => 2, 2 => 2, 3 => 2}
We are half way there. We have a hash that already has the information about which element or elements occur the most. Remember that the goal of the method is to return an array. How can we return the desired array from the hash? I will post the answer later today. But here's a clue: hashes have methods that allow you to get information from them. Take a look at the methods in the Hash object to see if there are any that will help us. You can see what methods are in hash objects by creating an empty hash and calling the methods method on it.
Glenn
Here is the 3rd hint.
We've already created a hash, and used the each method to start the hash out with a key for each unique element of the hash, and we've already set the value for each key in the hash to be equal to 0.
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
puts h.inspect # {1 => 0, 2 => 0, 3 => 0}
Now, we are ready to count how many times each element in the array actually occurs.
a.each { |e| h[e] += 1 }
puts h.inspect # {1 => 2, 2 => 2, 3 => 2}
We are half way there. We have a hash that already has the information about which element or elements occur the most. Remember that the goal of the method is to return an array. How can we return the desired array from the hash? I will post the answer later today. But here's a clue: hashes have methods that allow you to get information from them. Take a look at the methods in the Hash object to see if there are any that will help us. You can see what methods are in hash objects by creating an empty hash and calling the methods method on it.
Glenn
Friday, July 10, 2009
Hint #2 for the mode homework assignment
Hi All,
This is a bit of a spoiler is you are trying to do the homework on your own. But if you need a little help, please read on:
To create a hash of an array, you can create an empty array, then add each value of the array to the hash as a key and set the value of each key to be equal to 0.
Like this:
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
Hint #3 to follow tomorrow morning.
Enjoy your weekend!
Glenn
This is a bit of a spoiler is you are trying to do the homework on your own. But if you need a little help, please read on:
To create a hash of an array, you can create an empty array, then add each value of the array to the hash as a key and set the value of each key to be equal to 0.
Like this:
h = Hash.new
a = [1, 2, 2, 3, 3, 1]
a.each { |e| h[e] = 0 }
Hint #3 to follow tomorrow morning.
Enjoy your weekend!
Glenn
Hint #1 for the mode homework assignment
Hi,
Here are a couple of hints for this week's assignment.
A hash is a good way of storing pairs of objects that are related to each other in some way. The book gives states and their abbreviations as good examples of this:
h = {'Massachusetts' => 'MA', 'New York' => 'NY'}
To get the abbreviation of Massacusetts, you'd use the following:
puts h['Massachusetts'] # MA
puts h['New York'] # NY
To add another value to the has after it's been create, do this:
h['New Jersey'] = 'NJ'
puts h['New Jersey'] # NJ
But referencing a key that isn't already in the has returns a nil object.
puts h['Utah'] # nil
You can use a hash to count the number of times each element appears in a given array. Can you think of how to do this?
Look for Hint #2 later in the day...
Glenn
Here are a couple of hints for this week's assignment.
A hash is a good way of storing pairs of objects that are related to each other in some way. The book gives states and their abbreviations as good examples of this:
h = {'Massachusetts' => 'MA', 'New York' => 'NY'}
To get the abbreviation of Massacusetts, you'd use the following:
puts h['Massachusetts'] # MA
puts h['New York'] # NY
To add another value to the has after it's been create, do this:
h['New Jersey'] = 'NJ'
puts h['New Jersey'] # NJ
But referencing a key that isn't already in the has returns a nil object.
puts h['Utah'] # nil
You can use a hash to count the number of times each element appears in a given array. Can you think of how to do this?
Look for Hint #2 later in the day...
Glenn
Tuesday, July 7, 2009
Assignment for the July 13th class
Hi All,
For next week's class, the assignment is to write a method for the Array class that returns the mode of a given array. The mode in statistics is the most commonly occurring value or values. If there is a tie, then all of the numbers in the tie are considered the mode, so the return value of the method should be an array with 1 or more methods.
To start you off, here is some code.
class Array
   def mode
     ... your code goes here ...
   end
end
[100, 2, -10, 52.7, 2, nil].mode # returns [2]
[17.1, 2, 142.3, -22, nil, 17.1, 2].mode # returns [2, 17.1] or [17.1, 2]
To solve this, you will need to use a hash. Solving it without using a hash will be very difficult.
Good luck!
Please email or post a comment if you have any questions. This is a tough assignment, so don't be discouraged if it seems hard to do!
Glenn
For next week's class, the assignment is to write a method for the Array class that returns the mode of a given array. The mode in statistics is the most commonly occurring value or values. If there is a tie, then all of the numbers in the tie are considered the mode, so the return value of the method should be an array with 1 or more methods.
To start you off, here is some code.
class Array
   def mode
     ... your code goes here ...
   end
end
[100, 2, -10, 52.7, 2, nil].mode # returns [2]
[17.1, 2, 142.3, -22, nil, 17.1, 2].mode # returns [2, 17.1] or [17.1, 2]
To solve this, you will need to use a hash. Solving it without using a hash will be very difficult.
Good luck!
Please email or post a comment if you have any questions. This is a tough assignment, so don't be discouraged if it seems hard to do!
Glenn
minimum method for the Array class
Hi,
I used the wrong method in class last night in the solution for the minimum method. I used collect the collect method on the array to get rid of the nil elements when I should have used select.
Here's the correct way to do it:
class Array
   def minimum
     self.select { |e| e != nil }.sort.first
   end
end
puts [1, 2, -10, nil, 52.7].minimum # -10
You can also get rid of the nil elements using the compact method:
class Array
   def minimum
     self.compact.sort.first
   end
end
puts [1, 2, -10, nil, 52.7].minimum # -10
I used the wrong method in class last night in the solution for the minimum method. I used collect the collect method on the array to get rid of the nil elements when I should have used select.
Here's the correct way to do it:
class Array
   def minimum
     self.select { |e| e != nil }.sort.first
   end
end
puts [1, 2, -10, nil, 52.7].minimum # -10
You can also get rid of the nil elements using the compact method:
class Array
   def minimum
     self.compact.sort.first
   end
end
puts [1, 2, -10, nil, 52.7].minimum # -10
Sunday, June 28, 2009
Assignment for June 29th
Hi All,
The assignment from last week's class was to create a method that will produce an array of 10 unique random integers between 1 and 10.
We will go over this assignment during the class on June 29th.
Thanks,
Glenn
The assignment from last week's class was to create a method that will produce an array of 10 unique random integers between 1 and 10.
We will go over this assignment during the class on June 29th.
Thanks,
Glenn
Answers to Ruby Review #3
What is the Ruby object that's a number but not an integer called?
Numbers that aren't integers are called floats.
What's the syntax of the Ruby case statement?
case x
   when 5 then puts 'x == 5'
   when 15 then puts 'x == 15'
   when 10 then puts 'x == 10'
   else puts "I don't know what x is equal to."
end
What happens if more than one of the statements within a case statement evaluates to true?
The first one is executed.
What objects can be stored in a Ruby array?
Any object can be stored in a Ruby array.
What is an iterator?
An iterator is a method that acts essentially like a loop.
What is a block?
A block is code that follows a method and intereacts with the code in the method.
What is the difference between a block that uses 'do' and 'end' and a block that uses '{' and '}'?
While there are differences, these differences are not important when you are first learning Ruby.
How do you pass a value into a method?
You create a method that accepts a value by adding a variable name (or names) within the parentheses following the method name on the def line. If a pre-defined method accepts a parameter (or parameters) they can be added following the method call (the parenthesis are usually optional).
How do you pass a value from a method into a block?
You pass control of execution fro the method to the block vi the yield method. You can pass an object from the method to the block by including that object after the yield method call. In this case as well, the parentheses are optional.
Numbers that aren't integers are called floats.
What's the syntax of the Ruby case statement?
case x
   when 5 then puts 'x == 5'
   when 15 then puts 'x == 15'
   when 10 then puts 'x == 10'
   else puts "I don't know what x is equal to."
end
What happens if more than one of the statements within a case statement evaluates to true?
The first one is executed.
What objects can be stored in a Ruby array?
Any object can be stored in a Ruby array.
What is an iterator?
An iterator is a method that acts essentially like a loop.
What is a block?
A block is code that follows a method and intereacts with the code in the method.
What is the difference between a block that uses 'do' and 'end' and a block that uses '{' and '}'?
While there are differences, these differences are not important when you are first learning Ruby.
How do you pass a value into a method?
You create a method that accepts a value by adding a variable name (or names) within the parentheses following the method name on the def line. If a pre-defined method accepts a parameter (or parameters) they can be added following the method call (the parenthesis are usually optional).
How do you pass a value from a method into a block?
You pass control of execution fro the method to the block vi the yield method. You can pass an object from the method to the block by including that object after the yield method call. In this case as well, the parentheses are optional.
Saturday, June 20, 2009
Answers to Ruby Review #2
What does dynamic typing mean?
Dynamic typing means that you don't have the declare the type, or class, of a variable before using it.
What does static typing mean?
Static typing means that you do have to declare the type of every variable.
Which kind of language is Ruby?
Ruby is a dynamically typed language.
What is string interpolation?
String interpolation is the process of inserting the value of a variable into a string that is defined with double quotes.
For example:
name = 'Glenn'
puts "My name is #{name}." # My name is Glenn.
How do you increment numbers in Ruby?
You increment numbers with +=. You can do analogous actions with -=, *= and /=.
For example:
x = 10
x += 2
puts x # writes 12 to the console
What's the difference between a Fixnum and a Bignum?
Finums are relatively small integers and Bignums relatively big ones.
For example:
puts 10.class # Fixnum
puts 10000000000.class # Bignum
How do you convert from a number to an string?
Use the to_s method on the number.
For example:
puts 10.to_s.class # String
How do you convert from a string to a number?
Use the to_i method.
For example:
puts '10'.to_i.class # Fixnum
If you try this on a string that can't be converted to a number, you get 0.
puts 'cat'.to_i # 0
What are three ways to loop in Ruby?
while, until and for.
What is the Ruby syntax for if-then-else?
x = 10
if x < 10
   puts 'x < 10'
elsif x > 10
   puts 'x > 10'
else
   puts 'x == 10'
end
Can you write an if-then on a single line?
Yes.
x = 10
puts 'x == 10' if x == 10 # x == 10
if x == 10 then puts 'x == 10' end # x == 10
The first example is far more common in Ruby.
Can you write an if-then-else on a single line?
Yes, by using the ternary operator.
x = 10
x == 10 ? (puts 'x == 10') : (puts 'x != 10') # x == 10
How do you take a slice out of a string?
puts 'Glenn'.slice(1, 2) # le
puts 'Glenn'.slice(-1, 1) # n
How do you reverse a string?
puts 'Glenn'.reverse # nnelG
What does the term 'receiver' mean?
The object on which the method is called.
What does the term 'destructive method' mean?
A method that changes the value of the receiver.
Are all methods that end in a '!' destructive methods?
No. But usually that is the case. This is a Ruby convention. It is not enforced by the Ruby interpretor.
Name the 2 Boolean objects.
The 2 Ruby Boolean objects are true and false.
What method does the puts method call on every parameter passed to it?
puts always calls the to_s method on objects that are passed to it.
What is the syntax of a Ruby case?
x = 10
case x
   when 5 then puts 'x == 5'
   when 15 then puts 'x == 15'
   when 10 then puts 'x == 10'
   else puts "I don't know what x is equal to."
end
Dynamic typing means that you don't have the declare the type, or class, of a variable before using it.
What does static typing mean?
Static typing means that you do have to declare the type of every variable.
Which kind of language is Ruby?
Ruby is a dynamically typed language.
What is string interpolation?
String interpolation is the process of inserting the value of a variable into a string that is defined with double quotes.
For example:
name = 'Glenn'
puts "My name is #{name}." # My name is Glenn.
How do you increment numbers in Ruby?
You increment numbers with +=. You can do analogous actions with -=, *= and /=.
For example:
x = 10
x += 2
puts x # writes 12 to the console
What's the difference between a Fixnum and a Bignum?
Finums are relatively small integers and Bignums relatively big ones.
For example:
puts 10.class # Fixnum
puts 10000000000.class # Bignum
How do you convert from a number to an string?
Use the to_s method on the number.
For example:
puts 10.to_s.class # String
How do you convert from a string to a number?
Use the to_i method.
For example:
puts '10'.to_i.class # Fixnum
If you try this on a string that can't be converted to a number, you get 0.
puts 'cat'.to_i # 0
What are three ways to loop in Ruby?
while, until and for.
What is the Ruby syntax for if-then-else?
x = 10
if x < 10
   puts 'x < 10'
elsif x > 10
   puts 'x > 10'
else
   puts 'x == 10'
end
Can you write an if-then on a single line?
Yes.
x = 10
puts 'x == 10' if x == 10 # x == 10
if x == 10 then puts 'x == 10' end # x == 10
The first example is far more common in Ruby.
Can you write an if-then-else on a single line?
Yes, by using the ternary operator.
x = 10
x == 10 ? (puts 'x == 10') : (puts 'x != 10') # x == 10
How do you take a slice out of a string?
puts 'Glenn'.slice(1, 2) # le
puts 'Glenn'.slice(-1, 1) # n
How do you reverse a string?
puts 'Glenn'.reverse # nnelG
What does the term 'receiver' mean?
The object on which the method is called.
What does the term 'destructive method' mean?
A method that changes the value of the receiver.
Are all methods that end in a '!' destructive methods?
No. But usually that is the case. This is a Ruby convention. It is not enforced by the Ruby interpretor.
Name the 2 Boolean objects.
The 2 Ruby Boolean objects are true and false.
What method does the puts method call on every parameter passed to it?
puts always calls the to_s method on objects that are passed to it.
What is the syntax of a Ruby case?
x = 10
case x
   when 5 then puts 'x == 5'
   when 15 then puts 'x == 15'
   when 10 then puts 'x == 10'
   else puts "I don't know what x is equal to."
end
Ruby Review #3
Ruby Course
Brookline Adult and Community Education
June 22, 2009
Review #3
What is the Ruby object that's a number but not an integer called?
What's the syntax of the Ruby case statement?
What happens if more than one of the statements within a case statement evaluates to true?
What objects can be stored in a Ruby array?
What is an iterator?
What is a block?
What is the difference between a block that uses 'do' and 'end' and a block that uses '{' and '}'?
How do you pass a value into a method?
How do you pass a value from a method into a block?
Brookline Adult and Community Education
June 22, 2009
Review #3
What is the Ruby object that's a number but not an integer called?
What's the syntax of the Ruby case statement?
What happens if more than one of the statements within a case statement evaluates to true?
What objects can be stored in a Ruby array?
What is an iterator?
What is a block?
What is the difference between a block that uses 'do' and 'end' and a block that uses '{' and '}'?
How do you pass a value into a method?
How do you pass a value from a method into a block?
Sunday, June 14, 2009
Answers to BACE Ruby Review #1
When was Ruby created?
Ruby was created in 1995, the same year that Java was created.
Who created it?
Yukihiro Matsumoto, known as "Matz" in the Ruby community.
Is Ruby an interpreted language or a compiled language?
Interpreted.
What's the difference?
Interpreted language do not need to be compiled, they are just executed.
What can you use irb for?
Interactive Ruby is good for testing small pieces of code.
How much does Ruby cost?
Ruby is free.
How can you tell which version of Ruby is installed on a computer?
Execute ruby -v at the command prompt.
What are the 'nouns' of object oriented programming called?
Objects.
What are the 'verbs' called?
Methods.
Name three Ruby classes that we talked about last week.
String, Fixnum and Bignum.
Name three methods.
puts, class, methods.
What are all methods called on?
All methods -- even puts -- are called on objects.
What do all methods return?
All methods return objects; sometimes the returnd object is meaningful and sometimes it isn't.
What does the nil object mean?
The absence of anything.
What is an array?
An array is a collection of objects.
What are two ways to create a String object?
s = 'cat'
s = String.new('cat')
What are two ways to create a Fixnum object?
n = 10
n = String.new(10)
What are two great reasons for learning Ruby?
It's compact and it can be fun.
What is the difference between the puts method and the print method?
puts inserts a new line character at the end of the string and print doesn't.
What is the popular Web development that's written in Ruby called?
Ruby on Rails, usually just called Rails.
Ruby was created in 1995, the same year that Java was created.
Who created it?
Yukihiro Matsumoto, known as "Matz" in the Ruby community.
Is Ruby an interpreted language or a compiled language?
Interpreted.
What's the difference?
Interpreted language do not need to be compiled, they are just executed.
What can you use irb for?
Interactive Ruby is good for testing small pieces of code.
How much does Ruby cost?
Ruby is free.
How can you tell which version of Ruby is installed on a computer?
Execute ruby -v at the command prompt.
What are the 'nouns' of object oriented programming called?
Objects.
What are the 'verbs' called?
Methods.
Name three Ruby classes that we talked about last week.
String, Fixnum and Bignum.
Name three methods.
puts, class, methods.
What are all methods called on?
All methods -- even puts -- are called on objects.
What do all methods return?
All methods return objects; sometimes the returnd object is meaningful and sometimes it isn't.
What does the nil object mean?
The absence of anything.
What is an array?
An array is a collection of objects.
What are two ways to create a String object?
s = 'cat'
s = String.new('cat')
What are two ways to create a Fixnum object?
n = 10
n = String.new(10)
What are two great reasons for learning Ruby?
It's compact and it can be fun.
What is the difference between the puts method and the print method?
puts inserts a new line character at the end of the string and print doesn't.
What is the popular Web development that's written in Ruby called?
Ruby on Rails, usually just called Rails.
Wednesday, June 10, 2009
Ruby Review #2
Ruby Course
Brookline Adult and Community Education
June 15, 2009
Review #2
What does dynamic typing mean?
What does static typing mean?
Which kind of language is Ruby?
What is string interpolation?
How do you increment numbers in Ruby?
What's the difference between a Fixnum and a Bignum?
How do you convert from a number to an string?
How do you convert from a string to a number?
What are three ways to loop in Ruby?
What is the Ruby syntax for if-then-else?
Can you write an if-then on a single line?
Can you write an if-then-else on a single line?
How do you take a slice out of a string?
How do you reverse a string?
What does the term 'receiver' mean?
What does the term 'destructive method' mean?
Are all methods that end in a '!' destructive methods?
Name the 2 Boolean objects.
What method does the puts method call on every parameter passed to it?
What is the syntax of a Ruby case?
Brookline Adult and Community Education
June 15, 2009
Review #2
What does dynamic typing mean?
What does static typing mean?
Which kind of language is Ruby?
What is string interpolation?
How do you increment numbers in Ruby?
What's the difference between a Fixnum and a Bignum?
How do you convert from a number to an string?
How do you convert from a string to a number?
What are three ways to loop in Ruby?
What is the Ruby syntax for if-then-else?
Can you write an if-then on a single line?
Can you write an if-then-else on a single line?
How do you take a slice out of a string?
How do you reverse a string?
What does the term 'receiver' mean?
What does the term 'destructive method' mean?
Are all methods that end in a '!' destructive methods?
Name the 2 Boolean objects.
What method does the puts method call on every parameter passed to it?
What is the syntax of a Ruby case?
Syllabus
Introduction to Computer Programming with Ruby
Course Outline
Brookline Adult & Community Education
June 1, 2009 – July 20, 2009
6:30 – 8:30 p.m.
Week 1, June 1: What is Object-Oriented Programming?
Reading: RVQG, Chapters 1 and 2
Goals of this course
My background
What are two of the defining features of objects?
Brief background of Ruby
Installing Ruby v1.8.6
Interactive Ruby (IRB)
The course textbook: Ruby: Visual QuickStart Guide by Larry Ullman
Week 2, June 8: Strings, Numbers and Flow Control
Reading: RVQG, Chapters 3 and 5
Strings
Numbers
Conditionals
do loops
for loops
Iterators
Week 3, June 15: Collections
Reading: RVQG, Chapter 4
Arrays
Ranges
Hashes
Week 4, June 22: Methods
Reading: RVQG, Chapter 6
Return values of methods
Taking arguments
Object-dot notation
Duck typing
Blocks
Week 5, June 29: Classes
Reading: RVQG, Chapter 7
Classes as blueprints for objects
Classes as objects
Constructors
Instance variables
Making an object out of a class
Modifying existing classes
Creating custom classes
Encapsulation
Week 6, July 6: Inheritance
Reading: RVQG, Chapter 8
What is inheritance?
How is it useful?
Can it be overused?
Single inheritance
Week 7, July 13: Modules
Reading: RVQG, Chapter 9
Mixing functionality into a class
Extending the functionality of an object
Week 8, July 20: Review and Next Steps
Review
Next steps
Course Outline
Brookline Adult & Community Education
June 1, 2009 – July 20, 2009
6:30 – 8:30 p.m.
Week 1, June 1: What is Object-Oriented Programming?
Reading: RVQG, Chapters 1 and 2
Goals of this course
My background
What are two of the defining features of objects?
Brief background of Ruby
Installing Ruby v1.8.6
Interactive Ruby (IRB)
The course textbook: Ruby: Visual QuickStart Guide by Larry Ullman
Week 2, June 8: Strings, Numbers and Flow Control
Reading: RVQG, Chapters 3 and 5
Strings
Numbers
Conditionals
do loops
for loops
Iterators
Week 3, June 15: Collections
Reading: RVQG, Chapter 4
Arrays
Ranges
Hashes
Week 4, June 22: Methods
Reading: RVQG, Chapter 6
Return values of methods
Taking arguments
Object-dot notation
Duck typing
Blocks
Week 5, June 29: Classes
Reading: RVQG, Chapter 7
Classes as blueprints for objects
Classes as objects
Constructors
Instance variables
Making an object out of a class
Modifying existing classes
Creating custom classes
Encapsulation
Week 6, July 6: Inheritance
Reading: RVQG, Chapter 8
What is inheritance?
How is it useful?
Can it be overused?
Single inheritance
Week 7, July 13: Modules
Reading: RVQG, Chapter 9
Mixing functionality into a class
Extending the functionality of an object
Week 8, July 20: Review and Next Steps
Review
Next steps
Friday, June 5, 2009
BACE Ruby Review #1
Hi All,
If you get the chance, please check out the Ruby quiz below.
I plan to have a similar quiz after every class.
Don't worry, this is not like a quiz from back in school. It's not meant to trip you up, and there won't be a grade. It is meant as a review of what we've covered in the course so far.
I will go over the answers at the start of the class next week.
Here you go:
When was Ruby created?
Who created it?
Is Ruby an interpreted language or a compiled language?
What's the difference?
What can you use irb for?
How much does Ruby cost?
How can you tell which version of Ruby is installed on a computer?
What are the 'nouns' of object oriented programming called?
What are the 'verbs' called?
Name three Ruby classes that we talked about last week.
Name three methods.
What are all methods called on?
What do all methods return?
What does the nil object mean?
What is an array?
What are two ways to create a String object?
What are two ways to create a Fixnum object?
What are two great reasons for learning Ruby?
What is the difference between the puts method and the print method?
What is the popular Web development that's written in Ruby called?
See you on Monday June 8th.
Glenn
If you get the chance, please check out the Ruby quiz below.
I plan to have a similar quiz after every class.
Don't worry, this is not like a quiz from back in school. It's not meant to trip you up, and there won't be a grade. It is meant as a review of what we've covered in the course so far.
I will go over the answers at the start of the class next week.
Here you go:
When was Ruby created?
Who created it?
Is Ruby an interpreted language or a compiled language?
What's the difference?
What can you use irb for?
How much does Ruby cost?
How can you tell which version of Ruby is installed on a computer?
What are the 'nouns' of object oriented programming called?
What are the 'verbs' called?
Name three Ruby classes that we talked about last week.
Name three methods.
What are all methods called on?
What do all methods return?
What does the nil object mean?
What is an array?
What are two ways to create a String object?
What are two ways to create a Fixnum object?
What are two great reasons for learning Ruby?
What is the difference between the puts method and the print method?
What is the popular Web development that's written in Ruby called?
See you on Monday June 8th.
Glenn
Wednesday, June 3, 2009
Welcome to BACERuby
Hi All,
Welcome to the BACE (Brookline Adult and Community Education) Ruby blog.
I will be posting regular blogs on our course on assignments, Ruby questions, Ruby tips and more.
Please check the blog regularly for information on the course.
Thanks!
Glenn
Welcome to the BACE (Brookline Adult and Community Education) Ruby blog.
I will be posting regular blogs on our course on assignments, Ruby questions, Ruby tips and more.
Please check the blog regularly for information on the course.
Thanks!
Glenn
Subscribe to:
Comments (Atom)