View on GitHub

Shawn Lindsey

Welcome. I like Ruby/Rails/Javascript.


Ruby Test Questions - The Great Big Ruby Test

Posted on May 9th, 2011.

My Giant List of Self Test Questions

Welcome to my Giant List of Ruby Questions.  My workflow has been to read the books listed below creating questions based on what I felt was important material. 

Questions are totally relevant for the latest and greatest Ruby versions. There are a handful of questions that ask about how older versions of Ruby behave differently.

This list of questions is certainly not for everyone, do with it what you want. Some of it may not make sense as all questions and answers were created for me personally to read and review. Hopefully nothing in there is wrong, but PLEASE let me know if there is an error!

Follow me on Twitter @ShawnLindsey and follow my personal project and its Twitter feed @CappedIn_Feed

I read each of these books in this order, creating questions along the way.

  1. The Pickaxe book
  2. The Well Grounded Rubyist
  3. Eloquent Ruby

And here are the questions. Answers follow.

It's good to copy and paste these and keep the questions in one file and the answers in another. Just toggle between them for review.


1. Demonstrate two ways to create an empty hash
2. Build a hash with two symbols as keys that each have different strings as values
3. Demonstrate how to pass a key into a hash
*4. What is returned if you pass a key that doesnt exist into a hash?
5. Demonstrate how to change the value assoc with a key in a hash
6. Are hashes ordered? Does it matter order of Keys and Pairs?
7. How would you return all the keys in a hash?
8. These keys that are returned... what is their class?
9. How do you see if a key is in a hash?
10. How do you return all the values from a hash?
11. How would you merge one hash into another hash?
12. How would you add a key value pair to an existing hash?
13. Are these both strings "one" ... 'one'
14. Make a string with quotes inside the string... in a couple ways
15. Why would you use double or single quotes?
16. What are some common escape charactors and how do you escape them?
17. How do you use flexible quotes to not have to worry about the above? i.e. this is a great way to create a string
18. flexible quotes with the delimiter can be used to handle newlines ... demonstrate...
19. What is a here document? describe and create one in ruby
20. What operator will concatinate 2 strings? Does it leave the strings in place?
21. Demonstrate how to concatinate to the end of a string
22. What is the shovel operator and what does it do for strings?
23. What is the difference between += and << ?
24. What is the output? "\n".size What is "\t"?
25. can you escape charactors in a ' ' single quote?
26. How do you interpolate into a string?
*27. Show two ways to get the 4th - 6th letters out of "One is less than two" *ruby1.9 see below question too
28. tell me about how this is different in 1.8 and 1.9 ... x = string[1] how do you get what you *usually* want here in 1.8
29. How would you split this string? "One two three" what do you get back when split?
30. Show how you would split with a reg expression
+31. Use split and join on strings/array. Is join valid on strings? What does join do to an array? what does it do to a string?
+32. a = "one" b = "one" .. does a == b? does a.object_id == b.object_id? What does == usually evalutate for
33. Is nil an object?
34. nil.nil? returns?
+35. nil.to_s returns?
36. nil.inspect returns?
+37. describe the is_a? function.
38. one = :symbol1 ... two = :symbol1 ... are one and two the same object?
39. Discuss method names and thier relationship to symbols
40. Discuss Constants and their relationshop to symbols
41. is :symb == :"symb"? or :name = :"name"
+42. Ruby Symbols can never be garbage collected? is this true in 1.9?
43. How can you make a string into a symbol?
44. build a symbol that has spaces in it.
45. build a symbol with interpoation
46. What happens when you pass in a symbol to interpolated string?
47. What is the class of a Regualar Expression?
*48. Show two ways how you can match a string against a reg expression.. show...
*49. What is returned when you get a match? no match?
50. What do the following do in Regexp?
* []
\d (say "backslash d")
* \s (say "backslash s")
* \w backslash w
* \A backslash capital A
* \Z backslash captial Z vs \z
* ^
* $
51. What is greedy matching?
52. If more than one match what gets returned?
53. What is this called /? ... what is this called \?
54. Demonstrate a range match in Regexp
*55. Give an example of negating a character class
56. How do you get the negative of the characer classes?
57. How would you return a group of results in an array?
58. How can you take a string and return an array with all the words in it?
+59. what does sub method do on a string?
60. gsub?
61. Talk about global methods
62. What kind of Runtime Error is called when you call a method with wrong number of arguments?
63. Demonstrate how to define a method with default argument values
64. Demonstrate how to define a method that takes a variable amount of arguments
+65. if nothing is passed into a method with a variable arg, what is the value of that arg in the method?
66. How to you specify a return value in a method? what if you do not specify a return value?
67. Show two ways to call a method defined in the same class as the method you are in now.
68. define a private method in a class
69. talk about if you can call a private method from within another method of that class. How can you not call it?
70. How do you declare a top level constant? How can you reference it?
71. What about declaring constants in a class and referenceing them?
+72. Do Nested classes inheret constant values?
+73. Do subclasses inheret constants from parent classes?
74. If in nested class ... and ...Constant declared in both the parent class and in the inherited class which would win?
75. Describe static(lexical) scoping and dynamic scoping.
76. What kind of statements return a value in Ruby?
77. Write an if then else in Ruby
78. Write an if then else in ruby that assigns a value to a variable. What if the result of a if then statement does not assign a value? What is returned?
+79. Assign a value with a condition operator
80. assign a value with a statement modifier
81. write an unless statement
82. write a while statement
83. write a break statement in a loop, does it stop the whole loop?
84. write a next statement
85. write a for statement
85b. All of the above. do these change the current scope? do they pull in local variables? if you change these local vars do they change afger the while/unles/for stuff
+86. What are the things that evaluate to false when put into a conditon statement?
87. What does require do? demonstrate its call
+88. What does the Class method ancestors do when called?
89. Talk about the exception class tree.
90. Write a rescue clause. Does a rescue have to be in a begin / end clause?
91. What does method .. fail ... do?
92. If an error is a RuntimeError is it also a StandardError?
93. What is a synonym for fail?
94. How could you define and raise your own exception you defined?
95. What class is all this assert_equal and assert_raise stuff in... what is it>
96. Can each method use do end and { } ?
97. What does map do on an array? what is a synonym for it?
*98. What can you do to find all the matching elements in an array... how do you implement?
99. What is another name for this above method?
100. What method will get the first match in an array?
101. What does inject do? What "traditionaly returns an array and what traditionally just returns a number?"
102. Is a range a collection that can be used with methods like map?
*103. What does this do?"example_file.txt") do |file|
104. Demonstrate how to pass a block into a method... describe what is going on
105. Can you call yield multiple times on a block?
106. How can you check if a method was called with a block?
107. Show how you can assign a block to a variable, can you pass in two lambdas to a method and never use a &?
*108. Show another way to call a code block other than ..
109.How would you pass in a code block (lambda) to a method expecting a code block?
110. how would you define a method that explicitly takes a code block? what if you explicity define a code block and don't pass in a block?
111. Demonstrate 5 ways to do a loop from 1 .. 10 that prints the number.. not zero!
*112. Describe the differences between using lambda and What is shorthand for
do some examples of the above.
+113. Define a struct in ruby
114.Why might you use a Struct instead of a Hash?
+115. What is a Binding object and how do you use it... how do you get a binding?
116. How do you comment out a line of code?
117. How do you comment out a block of code?
118. What is a bad way to ask for instance variable values in a class... show two ways?
119. Show how to create accessor methods to_return instance variables
120. What is the good way to get read access to a instance variable?
121. What is the good way to get read / write access to an instance variable?
122. What is a good way to initialize a lot of instance variables when creating an object?
123 if a method returned self what is it returning?
124 what method definded in all Ruby objects is called when you do string interpolation and in that have an object? e.g. "hello and #{object_name}"
125. What will inspect do on an object?
126. Can you re open an existing ruby class? How do you do it?
*127. How would you check if a class had inherited from another class... ie the class has another class as a parent...?
128. What do all classes ulitmatly inheret from?
129. rand(6) returns values between x and y.. fill in x and y
130. Why can't you call method 'ancestors' on an object created by a call to e.g. chico ="Chico") .... you can not say chico.ancestors.include?(Dog) why?
131. if you try to call an undefined method on an object what Exception will be thrown?
132. Why do you do subclasses in general?
133. How can a subclass also get the functionality of the parent class when it overrides a method in the parent class?
134. can you call super 'cross method'? i.e. can you be in method "growl" in the subclass and call super.bark to try to get the functionality from the SuperClass method "bark"
135. What kind of Exception will you get from the above?
136. describe assert_raise and give an example
137. How do you define a module?
138. Can you instantiate a module?
139. How do you get a module's functionality into a class?
*140. What is a good catchall in Unit::Test that will assert that no Exceptions thrown?
141. Can a module method affect an instance variable in the class that includes it?
142. if a class that includes a module adds a method that is also in the module which one wins?
143. Are class names really just constants?
144. How can you reference nested classes?
145. If you define a nested class called String does this have normal string methods with it?
146. When you say something like ::String what is going on?
147. which is right .... class dog ... Class dog ... class Dog ...or... Class Dog
148. is it True or true?
149. What effect does this have ... MyString = ::String
150. what does method const_get do? Where is const_get located?
151. How can you get a list of constants for a class?
152. How would you test if something is an Object?
153. Is something that is defined as a class an object? class Dog ... does this respond true to Dog.is_a?(Object)
+154. How can you define a method on an individual object? What is this called? Show THREE ways to do it!!!
155. Are other objects of this class affected by these singleton methods?
156. Show 4 ways to define a class level method
157. Can you define two methods with the same name ... one an instance level method the other a class level method?
158. Do classes and instances share variables?
159. if you have a class statement what is returned? e.g. statement = class Dog ..... end
160. if you return self in a class statement what is returned?
161. If you have an instance of a class... [say] fido and want to call a class level method from this instance variable how can you do it?
162. Describe what this is doing ... class AboutMessagePassing < EdgeCase::Koan
163. So if you have an object and want to call one of its methods what are 2 ways to do it? Which one is used in something like metaprogramming?
164. Give some examples of dynamic ways to send an object a message
165. What is another way to call the send method and why could it be good?
+166. How can you check if an object knows how to handle to a message?
+167. show the two ways you can call an instance method passing in an array of args of unknown size
168. What is method_missing and how do you define it?
169. Describe the relationship between respond_to? and a class where method_missing is defined.
170. How can you make method_missing handle some messages and not handle other messages? talk about what you might do with respond_to? here also
171. talk about a forward proxy and reverse proxy
*172. What is ⌘ ...and ... ⌥ ... and ... ⇆ .... and ⇧
173. What are some differences between blocks formed with { } and do ... end
174. When you have bark(arg1,arg2) do |x,y|
... code ...
end show an example of how you would call this...
+175. Give an example of a Class method that is always created with every object
176. class File has a lot of class methods. What is an instance of class file though?
*177. describe and implement the singleton pattern where you are creating a logging object and only one is ever created.
178. describe the pattern where you use class methods [say] to reopen the class and provide a new way to initialize it
179. If you pass in an object to another object of same class how can you access the passed in objects instance variables?
*180. discuss obj.clone
181. What is the constant that gives you the ruby version you are using?
182. What is Ruby's top level self?
183. Are top level methods private? protected? or Public?
184. One of his main points was that in Ruby you are always sending a message to an object. If you don't explicitly say which object you want to send the message to, Ruby sends it to self. Is this true?
+185. If a program wants to use a module how does it do that?
186. what is the . operator do?
187. Can you use . and :: interchangeabley when calling a method on an object instance?
*188. What does p do?
189. Talk about how Modules define a namespace and how you use the scope operator to access things in the module.
190. How does ruby implememnt multiple inheritance?
191. how do you mixin a module to a class to make the module methods available as instance methods?
192. do you need to use require with include?
+193. How do you use the Comparable mixin?
+194. What is the Enumerable module?
195. write a class that includes Enumerable and Comparable
196. What is the operator that checks if something is defined and if it is returns it... otherwise it evaluates and returns the right side ... and remember it will create that variable because before it was undefined
197. how will ruby look up method names between, class, superclass, multiple modules?
198. what is the difference between load and require
199. Talk about the scope of variables and methods in a file that was loaded or required
200. Can you do an include Classname within another class?
201. What is this statement doing? x =
202. Can you define a method initialize in a module?
203. What is the difference between include, require, and load
204. Can you define two methods that accept different amount of args that Ruby will determine which one to use based on arg list?
205. can you say attr_accessor :purchases ... if purchases is a class level variable?
206. Can a subclass access a private method in the parent class?
207. Does x = [] x[9999] << "Hello" create a huge array?
208. Talk about 2 ways to do a deep copy of an object
*209. What kind of objects can't be Marshaled
210. Show an example of parallel assignment in Ruby
*211. Describe this parallel assignment
*212. Describe and & , or ||, ! not, which has lower precedence of the pairs
213. How can you check if something has been defined in your program
+214. What is the regualr expresion pattern match operator and negation of that? What does it return. What is difference between that and match method?
215. what is the difference between shape.eql?(obj) and shape.equal?(obj)
*216. How do you define a global Ruby variable? Name 2 special ruby global variables
217. write an exception that saves the exception object to a variable, and handles two exception types
218. describe the === operator
219. describe else in a resuce clause
220. talk about all the pieces in a rescue clause... and then talk about a rescue statement modifier
+221. talk about retry
222. Why would you put raise in a rescue clause?
*223. if you just put a raise statement what happens?
224. What happens with a raise "Error message here"
225. What happens with raise ArgumentError, "Message", caller[1..-1]
226. Describe and write a catch / throw
227. use the ? : statement
228. Give 3 examples of classes and modules that are automatically built in
229. In Ruby syntax how are expressions and statements termintated?
230. How can you continue an expression on the next line?
+231. What are BEGIN and END ? write some
232. Describe generalized delimited input
*233. What are the basic types in Ruby?
234. can you make a here document anywhere?
235. Describe the convention of capitals in constants AND class names and modules
*236. Talk about false and nil ... as in thier names. describe how to create a singleton class like these where only 1 object per class can be created
237. does FALSE = false? TRUE = true and NIL = nil?
238. What is the name of the current file constant? current line constant?
239. What responds true to object.nil?
*240. Can you define a Constant in a method?
*241. Do you have to initialize class variables before use?
+242. Describe class variables defined at the top level
243. Are class variables shared by children of the class they are defined in?
244. Are instance variables available to class methods?
++245. Does a block take on the set of local variables in existance when the block is created?
*246. What are some examples of pre-defined r/o read only variables in ruby?
*247. How can you define a shell command
248. can you use the scope operator to get a local variable or instance variable out of a class?
+249. How are ruby's comparison methods implemented?
250. what can you use instead of the keyword "then"?
*251. Describe the two case statements
252. Describe a definition (def) with an unadorned method name outside a class or module definition
+253. Can a method argument list reference an argument that precedes it in the argument list?
254. Can you pass a block to any method?
*255. Describe the order and things that can be passed into a method
256. What if you do not indicate a reciever for a message.. ie calling a method
257. What does calling super do? and talk about parameters with this call
258. if an operator is redefinable what does it look like method wise...
259. what does this def do?
def attr=(val)
*260. What is aliasing?
+261. can you alias instance variables? local variables? class variables? constants?
+262. what is done when you [say] include in a class definition? what happens when you write "include"
*263. what happens if you overide new?
*264. what does module_function :sin .... do when written in a module?
265. what is a closure?
*266. what has higher precedence? do .. end or {}
*267. describe the 3 places an exception can be handled
268. is the condition ? return value : other return value good for long if then / else things?
269. Can you have more than one method paramenter with a & .... explain
270. Can you pass in a &name and a code block to a method?
271. Can you pass in two code blocks to a method?
272. if you pass in a lambda that needs to be the "block" thus responding to block_given describe how you pass that in.
273. if you pass in a block of code without &'s' will that be a "block" of code ...responding to block_given?
274. Can you call .... just like that... nothing else?
275. What is another way to say
276. How do you execute a method on an object dynamically at runtime?
+277. in each with index you pass in two parameters which is which?
+278. What are the 4 evals? and what are the differences
279. How do you create Binding objects? Where is the binding function located?
280. What are binding objects?
*281. Describe the two method objects you can create
282. what does unbind do?
*283. how do you create a Method object and an UnboundMethod object?
284. What does class_eval do?
285. what does instance_eval do?
x.instance_eval or Object.instance_eval { ..block..}
286. What has higher precedence? {} or do/end. What other differnces are there between the two?
287. What is prefered in Ruby generally or proc or lambda? is proc = lambda?
*288. how can you run an external process (it replaces the current process)
289. What is the best way to define a class method self.meth_name or ClassName.meth_name? why?
+290. What does "inherited" method do... explain it.
*291. What are the 3 types of conversion performed by the interpreter. Describe each.
*292. Ruby objects have three components, name them.
293. What does this code do (x is a variable) class << x ... what is another way to do this?
294. When you do the above what happens as far as class structure?
295. String is an instance of what class?
296. talk about defining a singleton method on String....and how it is the same as a defining a singleton method variable x which is of class Person
def String.say_hi def x.say_hi
..code.. ...code...
end end
+297. Describe obj.extend(<mod.+)
298. When a class includes a module describe what happens as far as how they link together.
299. What is the difference between calling include ModuleName and extend ModuleName in a class definition?
300. When a class definition is executed ... talk about the value off self.class
301 When a class definitoin is executed... talk about the value of
302. Can you define two methods with the same name... one a class method, the other an instance method?
303. While a class definition is being executed talk about the methods available to it
304. talk about how attr_accessor works
305. What does attr do in a class?
306. Talk about class instance variables and object instance variables.
307. How can you add functionality to when classes and modules are defined?
*308. Can you use Ruby's keywords as variables? what about method names?
309. Can you include a class in another class?
310. If a class Dog < Animal ... and Animal has class methods... such as Animal.make_noise ... can you also say Dog.make_noise
311. When you execute a class method you are sending a message to the ____ object itself
312. What happens when you define methods at the top level
313. How can you change the visibility of a method in subclass from that of its parent class ie a_method is private in parent but public in subclasses
*314. How can you iterate over all the objects in your program?... well not all... which objects are not in there?
*315. How can you get a list of all superclasses of a class? how can you get a list of all the classes and modules?
316. when you have class Dog ... end and in your code you later say Dog.private_instance_methods(false) to get a list of the private instance methods... describe where this method is and how it was found
+317. What are all the ruby keywords
+318. Talk about the difference between alias and alias_method
*319. In a Hash is the key :one the same as "one"?
320. When you have xx ="Cat") yy ="Cat") how is it that xx == yy ... they are different objects...
*321. Give 3 examples of operators that can be overriden and 3 examples of operators that connot be... how is it that they can be overridden?
322. How can you erase all the keys and values in a hash?
+323. how can you iterate over all the key/values in a hash and how can you iterate through each key.. or each value
324. Describe what is going on when a class definition is first encountered by the parser. What happens to @@vars ... what about the logic in the class statement that is not in "def's" is this stuff just executed once when the parser goes through?
325. Describe and diagram the ruby class / object model
+326. Talk about the * operator and passing in variable args... most specifically the case when you pass in an array to a method that catches *args ... not args
+327. Talk about what things are propogated into current scope in a required file
*328. What does -cw do when you do ruby -cw prog.rb -v? --version? -e?
*329. How would you get a line of input from the the keyboard? How would you read the lines of a file?
*330. How can you get a lot of ruby config info? for example where is Ruby's executable files?
+331. what is the standard library
*332. Name a couple of files that have some standard library facilities that are in Config::CONFIG["rubylibdir"]... you may require these files to get some additional functionality
333. Talk about the terms library and extension
*334. What is the global variable that has ruby's load path's stored?
335. How do you start an irb session? what if you have a file with all kinds of classes and stuff that you want in memory during your irb session?
336. What is RDoc and ri
337. What are # and :: in ri referencing?
+338. Very simply what does rake do?
***339. Write a loop statement
***340. Use while and until as statement modifiers and use each at the begining and end of a loop construct.
*341. talk about defining a namespace and a task in rake
*342. what do you use to describe a namespace and task in Rake?
+343. how can you see all the tasks defined in a Rakefile?
*344. What is RubyGems?
*345. What is the extension on gem files?
*346. Describe where the 'gem' command will look for gems
+347. what command line option can you give to gem to make it just look locally
348. does encountering a return in method halt the method?
349. What 2 ways can you get an object to call a private method?
+350. How can you be sure you are only calling public methods on an object?
351. the *arg in a method definition is a sponge type arguement... describe what this means and how vars in the parameters are assigned
352. do variables in Ruby hold values?
*353. talk about clone and dup in relation to freeze method
*354. What is the new method? is there a singleton new method and and instance new method?
355. if you have unassigned [say] local variables in a method definition will that be caught during the parse?
356. What can self be?
357. Describe the relationship between singleton methods and class methods
358. Show what it looks like to print out self for an instance of a class... what does it look like to print out the class object?
*359. If you have a variable and a method named the same thing(not smart) and you write that variable / method in your code what wins? and Why?
*360. name a case when you have to indicate self even when calling an instance method on an object.
361. What are the 3 types of variables?
362. How can you get the 'friendlier' version of global variables in use? instead of all the $: and $! stuff?
363. Do subclasses and parents share the same class variables?
*364. What can not take an explicit reciever? what is the one exception?
365. What are top level methods?
366. Why can top level methods be called from anywhere?
367. talk about this code... notice x will never be assigned a value
if false
x = 99

puts x
+368. What comparison operator is used in the when part of case statements
369. How can you do a repeat until loop in ruby?
370. looping and an iterator are a bit different terms... what is an iterator?
371. when you create a block for a method call ... do you have access to the local variables created before the block was made?
372. when creating a block how can you make sure you have varibales that are local to the block scope and do not "pull" in variables from the outside, and possibly change them
373. if you create a local variable in the block will it be available outside the block?
374. can you use rescue without anything after it?
375. talk about using a resuce in a method or code block...
376. Is ensure clause run even if an exception is not raised?
377. What are the literal constructors for ... ... Array .. Hash, Range, Regexp, Proc (lambda)
378. x = 1 + 2 is sytactic sugar ... how is it written verbosely?
379. How do you get modulus?
380. can your class define ! .... what does ! typically denote?
381. What is the splat operator? what does it do?
382. what happens with the following code?
x = "We are number"
y = 3
puts x + y
383. What is called when you try to do something like "Dog" + 9 ... does it work?
+384. Describe evaluating a local variable that isnt initalized and an instance variable that isnt initialized
+385. what happens if you try to access a nonexistnat element of a container or collection object?
*386. list some valuble string methods
*387. How do you find Ruby's encoding? what is the default?
*388. Write a hash with symbols as keys without the => notation
389. what two libraries do you need to do date and time stuff?
*390. show how to get a Date object from a string
391. What is different about hashes in Ruby 1.9?
*392. Show how to iterate through a hash with an index
393. what are the Array and String methods?
394. What does passing in 2 arguments do within the array literal? e.g. array[3,2]
*395. How do you add an element (or more) to the beginning of an array / take away first element? the end (add and take away)?
396. How can you get default values for a Hash when there is NO MATCH? talk about adding a block to the end of the call to new
+397. Show two ways to create a range... also what is difference between 2 and 3 dots
+398. What is the difference between #include and #cover for a range?
399. How do you use a set? What is it?
400. What are IO objects of IO class...?
+401. What are the IO constants that are automatically set when a program starts?
402. What is the global var for the global input record seperator ?
*403. Explain how you would change the standard output to say a file instead of the screen...
404. Every object has two classes... name them
405. How do you get inside the definition body of a singleton class?
406 Singleton classes of class objects sometimes called?
407. what is a special behavior of singleton methods of Class objects?
+408. What does the tap method do? what objects is it available for?
409. How can you modify a method so that additional functionality is added to it... it is called a passthrough...
*410. How can you open up the singleton of an object to add methods without the class << obj type of thing?
411. How do you create and call a new Proc object? 1.9
412. what does the proc method and lambda method do? 1.9
413. when you supply a code block to a method are you in fact sending a Proc object?
+414. if you have a &block_var in your methods definition argument list and you pass in a block... does this create a Proc object?
415. if when calling a method you have a proc (Proc object) that you want to use as the code block ... how do you tell the method that you want this proc (Proc object) to be the methods code block?
416. Do code blocks preserve the variables that were in existence at the time they were created?
417. can you call a proc with the wrong number of arguments?
418. What is the difference between lambda and proc's creation of Proc objects?
419. How can you get a bound method? what is it?
420. How can you get an unbound method... and then how can you bind it?
+421. If you have class B < A ... and .. you have an initialize method in A (the superclass) but not in B.. and you do a x = ... does the superclass initialize method get run?
*422. What is $SAFE
423. How can you pry open an instance and execute statements as if you were inside that instance?... thus you do change 'self'
*424. What is the difference between instance_eval and instance_exec?
+425. What will class_eval do?
+426. what does define_method do? how is it useful
*427. How do you implement a thread?
*428. if your program terminates with a thread still running what happens to it? How can you make sure it keeps running?
*429. What is a fiber?
*430. How do you return from a fiber to the calling context?
*431. How can you get a socket listening on a port?
*432. Threads run using code blocks... if you change a local variable in the thread code block will it be changed when the code block exits?
*433. the $1 $2 , ... $n are global reg ex match variables ... what about threads in respect to these?
*434. Describe Thread keys /values
*435. What is the difference between system("date") and `date` ?
*436. List 7 callbacks, or hooks that are common to tie into during the execution of a Ruby program
*437. How can you get a stacktrace of your execution?
438. What is the literal constructor for a regexp?
439. What responds to .match?
440. What is the difference between .match and =~ ?
+441. What are the 3 possible components of a regexp?
442. How do you match a "special charactor" what are the special charactors?
*443. Name some special escape secquences for common charactor classes
444. What is a regexp "capture"
*445. How do you get a capture? talk about it a bit..
*446. if you have a Matchdata object.... what does the matchdataobject.string method do? matchdataobject.captures meth? What are some useful Matchdata methods?
*447. Can you use nested () in a regexp?
*448. Describe some regular expression quantifiers, anchors, and modifiers
449. What can you do to a 'greedy' regualar expression to make it not greedy?
+450. How can you match a specific number of repetitions within a regular expression? e.g. you have 239-9769 and want to match that it is a phone number with 3 digigts a '-' and then 4 digits
*451. How can you specify a range for repetions in regexp matching?
*452. How would you write a look ahead assertion? What is it?
*453. How would you write a look behind assertion?
*454. Show how to do interpolation on a Regexp
*455. What if you are interpolating a string into a regular expression that has 'special' charactors e.g. a '.' the period takes on special significance in a regexp... how can you account for this?
456. Name some well know methods that take regular expressions as parameters
*****458.What does grep do?
+460. Can you override the assignment operator in a class? as in just override = ?
*461. How do you use Rdoc and ri together (simple example)
*462. How can you see all the gems with thier documentation on your machine?
+463. Describe two ways to implement a 2D array in Ruby.
464. What is a DNS server?
465. talk about the last argument passed into a method...
*466. How do you change which ruby textmate uses?
467. Can you say x = then open up the singleton of x with class << x ... code .. end ?
468. How do you output a line but not do a \n?
469. Why would you def <(other) or def >(other)?
470. What have you decided is the best way to form strings given most use cases?
471. if you have a method defined like ... methname(&block) ... end .... what if you do not pass a block to it when you call it?
+472. can you say something like ... return x,object,name,7,9 ... at the end of a method?
473. When you require a file do you need to put the .rb extension on it? e.g. require 'set.rb' do you even need the quotes?
++474. In Ruby are arguments passed by value or passed by reference? ** double check this with some googeling to get whole story
475. Can you call a block that expects 4 arguments with zero arguments
+476. REVIEW ALL SCOPE RULES IN PARTICULAR ABOUT BLOCKS AND SUCH if you pass in a variable reference to a block... change that reference to a new object withing the block.. exit block ... what is the value of the reference after you leave the block?
477. What would you use extra () within a method definition parameters list for?
478. Is this true? You can pass in the wrong number of arguments to a method... but you MUST pass in the correct number to a block...
*479. How can you get the last element of an array?
+480. What does !! operator do in Ruby?
*481. If you are in an each loop and and exception is raised that causes the program to terminate how can you execute the rest of the each loop?
+482. Describe the scope of variables and the use of while, until and for loops
+483. Talk about ruby being pass by value or pass by reference
*484. What does partition method do for a string?
*485. List all the % delimeters
486. How can you iterate over numbers from 5 to 1 (backwards)
+487. What is the difference between using a statement like .. for i in (1..8) .... end and (1..8).each do |i| ... end ....
488. In Ruby you actually can change constants... but how can you really make a CONSTANT a CONSTANT?
489. What does Object mix in to get all its power? :)
****490. What is an enemerator?
491. THE CODE BLOCK GETS THE CURRENT SCOPE AND CAN CHANGE THE CURRENT SCOPE!!! you only change the scope when you go into a def, a class definition, or a module definition
*492. What does defined? return? ... is it a keyword or a method?
*494. How can you find the postion of an element in an array?
*495. what is difference between p and pp
+496. Describe {instance|module|class}_{eval|exec} family of methods
+497. When you create a class what is the default behavior of ==
*498. What is the difference between instance_of? and kind_of?
*499. What class === only defined for? what if === is not defined for a class?
*500. What method does Hash use to compare a key passed in with the already stored keys? i.e. you can change the lookup behavior of a hash by overriding this method...
*501. Name two classes that you cannot declare singleton methods on instances of objects...
502. If you have a bunch of ways to create an instance of a class that all differ a bit how should you do this?
503. class Parent; def self.who_am_i; puts self; end; end; class Child < Parent; end; if you say Child.who_am_i what is printed?
+504. If you have a module and want to store a useful method in there that you can access without instanciating any object how would you do it?
****505. Do code blocks return a value? i.e. you pass a code block into a method...
506. Describe the term "Execute Around" and how it pertains to blocks
+507. Describle a danger when creating a block that you hold onto for a while... pass it around maybe...
+508. Describe lazy initialization with code blocks
*509. How do you make "new" method private for a class? i.e. x =
*510. Describe the at_exit hook.
*511. Describe set_trace_func and its use
*512. Describe the pattern where you are mixing in a module where you have some methods that should be mixed in as instance methods and some methods that should be class methods
*513. Describe what you get when you use SimpleDelegator ... after you have required 'delegate'... how to use...
*514. Describe the PathName class
515. What is the difference between is_a? and kind_of?
516. How can you dynamically define instance methods in a class?
*517. how do you get a charactor in a string at position 2 in 1.8 and 1.9?
*518. Talk about how Rails can use methods that are added to the script on the fly.
*519. talk about providing a block to an object being created with a call to new.. eg. jim = do |person| .... end
+520. When you define a method dynamically for a class using define_method(method_name) how do you get this newly defined method to have parameters?
+521. How can you end the execution of a block during its execution?
*522. Talk about some clever ways to create "singleton" type objects in ruby... as in only one instance of each
523. What are the 3 scope gates? Where scope changes?
*524. describe a top level instance variable?
525. Talk about rescuing from Exception ie ... in code .... rescue Exception => er
526. What are the differences between new method and initialize method?
527. What is self?

Find ANSWERS in next post.