i'm new swift , ios programming @ all.
i'm trying test out simple algorithm , need array of stacks. don't have fancy (stacks of ints do).
i got stack implementation the swift programming language documentation:
struct intstack { var items = [int]() mutating func push(item: int) { items.append(item) } mutating func pop() -> int { return items.removelast() } mutating func count() -> int { return items.count } mutating func show() { println(items) } } the count , show functions contribution. when try declare array of stacks error...
var lines = intstack()[5] "intstack" not have member named subscript
i'm guessing has optionals, can figure out is...
any help?
there no need declare size of stack when init it. jus calling should enough.
var lines = intstack() also note count() , show() methods should not mutating since don't modify struct in way.
Comments
Post a Comment