foo(**) # pass them to the next method end def positional(*) # accept positional arguments bar(*) # pass to the next method end def positional_keywords(*, **) # same as ... foobar(*, **) end
two seconds /^x*y?x*()\1$/ =~ "x" * 45000 + "a" #=> Regexp::TimeoutError is raised in two seconds my_long_rexp = Regexp.new('^x*y?x*()\1$', timeout: 4) my_long_rexp =~ "x" * 45000 + "a" # Regexp::TimeoutError is raised in four seconds
age: 12}, {name: "Butler", age: 9}], siblings: [{name: "Mary", age: 31}, {name: "Conrad", age: 38}] } case person in {name: "John", children: [{name: "Mark", age: age}]} p age end # those won't match because of :siblings key present
server # do connection with admin rights in 'devuser', _, 'dev-server.us-east- 1.rds.amazonaws.com' # connect to dev server in user, password, server # do regular connection end
NotFound = Data.define # ... implementation end #<data HTTPFetcher::Response body="<html..."> #<data HTTPFetcher::NotFound> case fetcher.get(url) in HTTPFetcher::Response(body) # process body variable in HTTPFetcher::NotFound # handle not found case end
0) up = origin.with(x: 1) right = origin.with(y: 1) up_and_right = up.with(y: 1) p origin # #<data Point x=0, y=0> p up # #<data Point x=1, y=0> p right # #<data Point x=0, y=1> p up_and_right # #<data Point x=1, y=1> out = origin.with(z: 1) # ArgumentError: unknown keyword: :z some_point = origin.with(1, 2) # ArgumentError: expected keyword arguments, got positional arguments