undefined method `last' for #<Hash:0x00007f303593d6d8>

876 Views Asked by At

trying the below code in a custom sdk in Workato

poll: lambda do |connection, input, last_updated_at|
      per_page = 1
      last_updated_at = (last_updated_at || input['since']).to_time.utc.iso8601
      candidates = get("https://api.stripe.com/v1/customers")
      last_updated_at = candidates.last["created"] unless candidates.blank?

Getting an error undefined method `last' for #Hash:0x00007f303593d6d8 at line:

1

There are 1 best solutions below

3
On

There is no Hash#last method. Hashes do keep their insertion order, but you should conceptually treat them as unordered. The concept of the "last" element of a Hash simply does not make sense.