0

Trying to get query results into an array. The example from the documentation shows this working...

let statement = try db.prepare(query)
var results = Array(statement)

...however when I try to compile this I get...

Ambiguous use of 'init'

... for the Array(statement)

If I change to this...

let statement = try db.prepare(query)
var results = Array<SQLite.Row>(statement)

I get this error...

Type of expression is ambiguous without more context

What can I do to make this work?

Kirby Todd
  • 11,254
  • 3
  • 32
  • 60

1 Answers1

0

You need to iterate through the rows to put them into an array:

for statement in try db.prepare(query) {
    yourArray.append(statement)
}
Xcoder
  • 1,433
  • 3
  • 17
  • 37