Swift Eureka hinge

I am creating an Eureka form and would like to place a loop on the form to create a list of steppes based on an array.

The code I'm trying to use is:

let itemNames = ["one","two","three"]

// Eureka From Set-up
form
    +++ Section("Select item values")

    for itemName in itemNames{
        <<< StepperRow() {
            $0.tag = itemName
            $0.title = itemName
            $0.value = 0
        }
    }

However, when I do this, I get an error in the StepperRow line, which reads:

Unary operator cannot be separated from its operand

So, it seems that Swift no longer thinks he is in shape and looks at the <character less than the line declaration.

Any thoughts on how to get around this?

+4
source share
2 answers

<<<is a binary operator that expects two operands ( lhs <<< rhs), whereas in the above example you just put it ( <<< operand).

"" for, , rhs, lhs ( lhs form +++ Section(...)). reduce. Eureka ( ), : ( +++ <<<, Eureka/Source/Core/Operators.swift)

form 
    +++ itemNames.reduce(Section("Select item values")) { (section, itemName) in
        section 
            <<< StepperRow() {
                $0.tag = itemName
                $0.title = itemName
                $0.value = 0
            }
    }
+2

:

let itemNames = ["one","two","three"]

// Eureka From Set-up
form
    +++ Section("Select item values")

    for itemName in itemNames{

    form.last

        <<< StepperRow() {
            $0.tag = itemName
            $0.title = itemName
            $0.value = 0
        }
    }

"form.last" for.loop.

+2

Source: https://habr.com/ru/post/1661295/


All Articles