snipplets.dev/~/Crystal/schedule.cr
2022-10-08 00:31:44 +03:00

19 lines
219 B
Crystal

def every(period : Time::Span, &block : -> T) forall T
spawn do
loop do
block.call
sleep period
end
end
end
every(2.seconds) {
puts "-@-@-"
}
every(4.seconds) {
puts "(-.-)Zzz..."
}
sleep