Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-622

Use default values for variables rather than setting default values via initializer for options structs

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:

      Description

      As of Swift 5.1 / SE-0242 the compiler will generate the initializers we need if we just provide the default values on the properties themselves.

      E.g. we can change any place we have something like the following:

      struct SomeOptions {
          var x: Int?
       
          init(x: Int? = nil) {
              self.x = x
          }
      }
      

      to just

      struct SomeOptions {
          var x: Int? = nil
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kaitlin.mahar Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: