Skip to content

Withable not working on custom types with init parameters #49

@Jeehut

Description

@Jeehut

Expected Behavior

When I have a Task type like so:

class Task: Withable {
    var name: String
    var absolutePriority: UInt64? = nil
}

I should be able to write code like this:

let tasks: [Task] = [
    SingleTask(name: "Task1").with { $0.absolutePriority = -100 },
    SingleTask(name: "Task2").with { $0.absolutePriority = -50 },
    SingleTask(name: "Task3").with { $0.absolutePriority = 0 },
    SingleTask(name: "Task4").with { $0.absolutePriority = 25 },
    SingleTask(name: "Task5").with { $0.absolutePriority = 50 },
]

Actual Behavior

It's not building because Withable requires my type not not have any parameters in the init method, which shouldn't be the case.

Steps to Reproduce the Problem

See code above.

Specifications

  • Version: 3.2.0
  • Platform: macOS 10.15.4
  • IDE Version: Xcode 11.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions