In this exercise you are to use irb
, a Ruby REPL, to evaluate various Ruby expressions
and compile a list of observations about Ruby based on what you see.
Note: This exercise is to be entirely experimental. Don't Google, read documentation, etc. It's just your group and irb
!
If you've got Ruby on your machine, irb
should be there, too.
On lectura, first do "rvm 2.2.4
" and ignore any error output. Then do "irb
".
3+4 _.class 7.<TAB><TAB> # 7. then hit TAB twice ("abc"*3).size.to_s s = RUBY_DESCRIPTION s[5,9] s[5..9] s[-2] "a test here".split.map {|s| s.size} 1032[3] s=`cal; who | wc` # backquotes! s.gsub!("7","seven"); print s "call 555-1212" =~ /[0-9]+/ [$`, $&, $'] # immediately after line above ('!'..'*').to_a { 1 => 2.0, :three => [!nil, "#{3+4}"] } x = Complex(2,3) * 2 + 7 Rational(1,3) * 300 if 1 < 2 then 3 else 4 end while line = gets; p line; end print 1 unless 2 < 3 3.+(4)
Create a plain text file named cle7.txt
with
Submit it on lectura with turnin
:
turnin 372-cle7 cle7.txt
Note: We might browse the files when done. To be anonymous, put your NetIDs at the end of the file, preceded by about fifty blank lines.