Result of call is unused

前端 未结 2 1248
再見小時候
再見小時候 2021-01-21 03:39

Right below the second comment, I receive an error of \"Result of call to \'taskForDeleteMethod\' is unused. Why is this when I use the results and error in the closure followin

2条回答
  •  猫巷女王i
    2021-01-21 04:03

    In earlier swift versions, you need not bother about the return value of a method. You may store it in any variable snd use it later or you may ignore it completely. Neither it gave any error nor a warning.

    But in swift 3.0 you need to specify whether you want to ignore the returned value or use it.

    1. If you want to use the returned value, you can create a variable/constant and store the value in it, i.e

    let value = taskForDELETEMethod {
        // Your code goes here
    }
    

    2. If you want to ignore the returned value, you can use _ ,i.e

    let _ = taskForDELETEMethod {
        // Your code goes here
    }
    

提交回复
热议问题