'Dr. Katie Bouman' ANITA = 'Dr. Anita Borg' def each yield RADIA yield KATIE yield ANITA end end PeopleDirectory.new.each do |name| puts name end Dr. Radia Perlman Dr. Katie Bouman Dr. Anita Borg
= 12345 def initialize(seed) @value = seed end def next @value = (A * @value + C) % M end end rng = LinearCongruentialGenerator.new(123) p rng.next p rng.next p rng.next
= 12345 def initialize(seed) @value = seed end def next @value = (A * @value + C) % M end end rng = LinearCongruentialGenerator.new(123) p rng.next p rng.next p rng.next 440917719 357222964 2107447239
def make_rng(value) Fiber.new do loop do value = (A * value + C) % M Fiber.yield(value) end end end rng = make_rng(123) p rng.resume p rng.resume p rng.resume
def make_rng(value) Fiber.new do loop do value = (A * value + C) % M Fiber.yield(value) end end end rng = make_rng(123) p rng.resume p rng.resume p rng.resume 440917719 357222964 2107447239
def make_rng(value) Enumerator.new do |enum| loop do value = (A * value + C) % M enum.yield(value) end end end rng = make_rng(123) p rng.next p rng.next p rng.next 440917719 357222964 2107447239
def make_rng(value) Enumerator.new do |enum| loop do value = (A * value + C) % M enum.yield(value) end end end rng = make_rng(123) p rng.next p rng.next p rng.next 440917719 357222964 2107447239
def make_rng(value) Enumerator.new do |enum| loop do value = (A * value + C) % M enum.yield(value) end end end rng = make_rng(123) p rng.take(2) [440917719, 357222964]
readable.each do |socket| fiber = $awaiting_readable.fetch(socket) fiber.resume end writable.each do |socket| fiber = $awaiting_writable.fetch(socket) fiber.resume end end
Fiber.yield $awaiting_readable.delete(socket) when :wait_writable $awaiting_writable[socket] = Fiber.current Fiber.yield $awaiting_writable.delete(socket) else end end
= Fiber.current Fiber.yield $awaiting_readable.delete(socket) when :wait_writable $awaiting_writable[socket] = Fiber.current Fiber.yield $awaiting_writable.delete(socket) else end end end
= Fiber.current Fiber.yield $awaiting_readable.delete(socket) when :wait_writable $awaiting_writable[socket] = Fiber.current Fiber.yield $awaiting_writable.delete(socket) else break end end end
Async::HTTP::Client.new(endpoint) Async do |task| task.async { p client.get("/").status } task.async { p client.get("/cv/").status } task.async { p client.get("/software/").status } task.async { p client.get("/talks/").status } task.async { p client.get("/toolbox/").status } end
Async::HTTP::Client.new(endpoint) Async do |task| task.async { p client.get("/").status } task.async { p client.get("/cv/").status } task.async { p client.get("/software/").status } task.async { p client.get("/talks/").status } task.async { p client.get("/toolbox/").status } end https://github.com/socketry/async