Documenting lesser-known features in Ruby
What is the output of
?????:?????:??
A: "?"
?? ? ?? : ?? ? ?? : ??
"?" ? "?" : "?" ? "?" : "?"
"?" ? "?" : ("?" ? "?" : "?")
"?" ? "?" : "?"
"?"
What is the output of
%%%%%%%%%%%
A: ""
%%%%%%%%%%%
%%% % %%% % %%%
"" % "" % ""
"" % ""
""
What is the output of
% % % % % % % %
A: "%"
% % % % % % % %
"%"%"%"%"%"
"%" % "%" % "%"
"%" % "%"
"%"
What is the result?
"RUG::B".gsub(/(.*)::/, '\&\&')
"RUG::RUG::B"
"RUG::B".gsub(/(.*)::/, '\\&\\&')
"RUG::RUG::B"
"RUG::B".gsub(/(.*)::/, '\\\&\\\&')
"\\&\\&B"
"RUG::B".gsub(/(.*)::/, "\&\&")
"&&B"
"RUG::B".gsub(/(.*)::/, "\\&\\&")
"RUG::RUG::B"
"RUG::B".gsub(/(.*)::/, "\\\&\\\&")
"RUG::RUG::B"
What is the result?
"RUG::B".gsub(/(.*)/, '\1')
"RUG::B"
"RUG::B".gsub(/(.*)/, '\\1')
"RUG::B"
"RUG::B".gsub(/(.*)/, '\\\1')
"\\1\\1"
"RUG::B".gsub(/(.*)/, "\1")
"\u0001\u0001"
"RUG::B".gsub(/(.*)/, "\\1")
"RUG::B"
"RUG::B".gsub(/(.*)/, "\\\1")
"\\\u0001\\\u0001"
How many ways does Ruby provide to embed a NULL Byte?
Hint: For example, "\x00"
embeds a null byte
A: 40
What?
"\0" "\x00" "\x0" "\u0000" "\u{0000}" "\u{000}" "\u{00}" "\u{0}" "\u{00000}" "\u{000000}" "\000" "\00" "\C-\0" "\C-\x00" "\C-\x0" "\C-\000" "\C-\00" "\C-@" "\C-\x40" "\C-\100" "\C-`" "\C-\x60" "\C-\140" "\C- " "\C-\x20" "\C-\40" "\c\0" "\c\x00" "\c\x0" "\c\000" "\c\00" "\c@" "\c\x40" "\c\100" "\c`" "\c\x60" "\c\140" "\c " "\c\x20" "\c\40"