Class 3: Ruby, continued
Held: Friday, 27 January 2017
We continue to investigate some issues in Ruby.
- Reflections on exercises
- Duck typing
- Additional characteristics of Ruby
- Meta discussion
- Object-oriented programming in Ruby
News / Etc.
- Welcome to day three of CSC 321!
- Today we conclude our exploration of Ruby and start on Rails.
- Next week, we will mostly explore Rails.
- We will have a visitor for the second half of class on Tuesday. Shu-Yang Lin, http://shuyanglin.com/. She will discuss design issues and more.
- I’m still working on the course Web site.
- It appears that RubyGems has some vulnerabilities https://www.ruby-lang.org/en/news/2017/08/29/multiple-vulnerabilities-in-rubygems/. I would suggest that you do your devleopment on Cloud 9, rather than on your personal computer.
- Do Rails for Zombies (Tueday)
- Read SaasBook, Chapter 4 (Tuesday)
- Do The introduction to Rails from SaasBook (Thursday; start before Tuesday)
Good things to do
- NEW Rosenfield Internship Talks, Today at 11 a.m. in JRC 101.
- NEW CS Extras today at 4:15 p.m.: Contracts
- NEW Writers@Grinnell Reading, Today at 6 p.m. in the Pioneer Bookshop.
- NEW Rosenfield symposium, next week. (Lots of different events)
A brief introduction to Ruby
- Modern programming language.
- “One” designer.
- Imperative, functional, and OOP characteristics.
- Good at “Get the job done quickly.”
- Very dynamic.
- Very popular.
- Everything (more or less) is an object.
- Includes anonymous functions, although with a different syntax than we might expect.
Disadvantage: Too many ways to express the same concept.
if TEST consequent consequent if TEST if TEST consequent end unless not TEST consquent end consequent unless not TEST
Some Ruby exercises
We will explore some of the examples from today’s assignment to see the different ways in which students approached problems.
sums_to_n?(vals,val) that returns true if any two distinct
vals (a list of values) sums to
multiple_of_4?(bitstring) that takes a string of 0’s and 1’s
(representing an unsigned integer) as input and returns true if the
string represents an integer divisible by four.
starts_with_consonant?(str) that determines if a string
starts with a consonant.
Additional characteristics of Ruby
What did you see as important characteristics of Ruby?