Choylton B. Higginbottom
Choylton B. Higginbottom

Reputation: 2304

Crystal language: is the first argument to delay in seconds or milliseconds?

I'm looking to use the delay method, but am unsure as to what unit of time the first argument is.

As a follow-up, is the argument an integer, float, or something else?

Upvotes: 1

Views: 134

Answers (2)

Jonne Haß
Jonne Haß

Reputation: 4857

The implementation calls to_f on the argument internally and interprets it as seconds, so you can pass anything that responds in a compatible way. This includes Time::Span instances, so things like delay(5.minutes) { puts "done" } work.

Upvotes: 3

Choylton B. Higginbottom
Choylton B. Higginbottom

Reputation: 2304

The delay time is in seconds, and is a float (or other number type with decimal precision)

Upvotes: 1

Related Questions