Idiosyncrätic

Ruby Quiz


@JanLelisJanuary 2016RUG::B

idiosyncratic-ruby.com

Documenting lesser-known features in Ruby

Question 1

There is a String method that will generate the "successor" of a string


"aaa".succ #=> "aab"
            

What's the result of:


"9z".succ #=> ?
              

Question 1


"9z".succ #=> "10a"
            

Bonus Question 1

What's the result of:


"z9".succ #=> ?
            

Bonus Question 1


"z9".succ #=> "aa0"
            

Question 2

There is the concept of "bundled gems" in Ruby.

These will be installed alongside Ruby.

How many gems are bundled with Ruby 2.3?

Question 2

There is the concept of "bundled gems" in Ruby.

These will be installed alongside Ruby.

How many gems are bundled with Ruby 2.3?

6

Bonus Question 2

Which ones?


power_assert 0.2.6
test-unit 3.1.5
minitest 5.8.3
rake 10.4.2
net-telnet 0.1.1
did_you_mean 1.0.0
            

Question 3

There is a String#split method,
which also accepts regexes:


"rug-b".split(/-/) #=> ["rug", "b"]
            

What will happen if we use a capturing group in the regex?


  "rug-b".split(/(-)/) #=> ?
              

Question 3


"rug-b".split(/(-)/) #=> ["rug", "-", "b"]
            

Bonus Question 3

What will happen if we use a multiple capturing groups?


"rug-b".split(/((-))/) #=> ?
            

Bonus Question 3

What will happen if we use a multiple capturing groups?


"rug-b".split(/((-))/) #=> ["rug", "-", "-", "b"]
            

Bonus Bonus


"rug-b".split(/(((((-)))))/)
#=> ["rug", "-", "-", "-", "-", "-", "b"]
            

"rug-b".split(/-(?=(.))/)
#=> ["rug", "b", "b"]
            

This was Ruby Quiz 1!

idiosyncratic-ruby.com

@JanLelis