# length is required
def pad(num, length:, char: "0")
num.to_s.rjust(length, char)
end
pad(42, length: 6) #=> "000042"
pad(42) #=> #<ArgumentError: missing keyword: length>
prepend(
Module.new do
define_method ...
end
)
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️