개발/swift

Swift How to ignore return value?

lemonade 2020. 12. 8. 10:00
반응형

How to ignore return value?

 

Sometimes you might want to ignore the return value while in other cases you might use it.

 

In that situation, you can use @discardableResult attribute!

 

 

Let's see example.

 

When you call update function like below.

 

You will see warning :(

 

 

You might fix the warning like this.

 

But it's ugly code.

 

 

In that case, you could use @discardableResult attribute.

 

 

It will fix warning!

 

Happy coding :)

 

반응형
그리드형