Documenting lesser-known features in Ruby
There is a String method that will generate the "successor" of a string
"aaa".succ #=> "aab"
What's the result of:
"9z".succ #=> ?
"9z".succ #=> "10a"
What's the result of:
"z9".succ #=> ?
"z9".succ #=> "aa0"
There is the concept of "bundled gems" in Ruby.
These will be installed alongside Ruby.
How many gems are bundled with Ruby 2.3?
There is the concept of "bundled gems" in Ruby.
These will be installed alongside Ruby.
How many gems are bundled with Ruby 2.3?
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
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(/(-)/) #=> ?
"rug-b".split(/(-)/) #=> ["rug", "-", "b"]
What will happen if we use a multiple capturing groups?
"rug-b".split(/((-))/) #=> ?
What will happen if we use a multiple capturing groups?
"rug-b".split(/((-))/) #=> ["rug", "-", "-", "b"]
"rug-b".split(/(((((-)))))/)
#=> ["rug", "-", "-", "-", "-", "-", "b"]
"rug-b".split(/-(?=(.))/)
#=> ["rug", "b", "b"]