introduction to ruby Flashcards
History of ruby:
What was ruby influenced by?
•It was also influenced by Eiffel and Lisp, Perl with Smalltalk-like features.
What is Ruby?
Ruby is a dynamic, reflective, general-purpose object-oriented programming language.
Ruby and Java Comparison
•Ruby
sleep 100
•Java
public class sleep{
public static void main (String[] args) throws InterruptedException {
Thread.sleep (100*1000);
}
}
Who was the designer of Ruby?
Ruby was first designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan.”
The ruby language syntax is sensitive to the…
capitalization of identifiers, in all cases treating capitalized variables as constants.
•The sigils $ and @ do not indicate variable data type as in Perl, but rather….
function as scope resolution operators.
•One of ruby’s features is that it is thoroughly object-oriented with _____ , ______ , _______
inheritance mixins and metaclasses
What is Duck typing?
you don’t need a type in order to invoke an existing method on an object - if a method is defined on it, you can invoke it.
The name comes from the phrase “If it looks like a duck and quacks like a duck, it’s a duck”
What is Dynamic typing?
Dynamic typing just says that types are associated with run-time values, not with static variables and parameters.
Everything is an _________ (even statements) and everything is executed imperatively (even _________)
•Everything is an expression (even statements) and everything is executed imperatively (even declarations)
A ruby feature is that Succinct and flexible _____ that minimizes ______________ and serves as a foundation for _______________ languages.
Succinct and flexible syntax that minimizes syntactic noise and serves as a foundation for domain-specific languages
Ruby features: Dynamic _________ and ________ of objects to facilitate ______________
Dynamic reflection and alteration of objects to facilitate metaprogramming
Ruby features: ___________, _________ and _________, with a unique block syntax
•Lexical closures, iterators and generators, with a unique block syntax
Ruby feature: Literal notation for ______, ______, ________________ and _______
Literal notation for arrays, hashes, regular expressions and symbols
Ruby feature: •Embedding code in _______(interpolation)
Ruby feature: •Embedding code in strings (interpolation)
Ruby features: _______arguments
Default arguments
Ruby features: •________ collection
•Garbage collection
Ruby features: •Four levels of variable scope (_____, ______, __________, and ______) denoted by sigils or the lack thereof
•Four levels of variable scope (global, class, instance, and local) denoted by sigils or the lack thereof
Ruby features: Strict ________ rules (everything is _____except ____and ___)
Strict boolean coercion rules (everything is true except false and nil)
Ruby features: __________ continuations
First-class continuations
Ruby features: ________ handling
•Exception handling
Ruby features: ________ overloading
Operator overloading
Ruby features: Built-in support for ________numbers, ________ numbers and ________ arithmetic
Built-in support for rational numbers, complex numbers and arbitrary-precision arithmetic
Ruby features: Custom dispatch behavior (through : ________and : ________)
Ruby features: Custom dispatch behavior (through method_missing and const_missing)
