简体   繁体   English

对于返回void的函数,什么都不做运算符是什么?

[英]What would be a do nothing operator for a function returning void?

I want to return nothing inside a function returning void. 我想在返回void的函数内不返回任何内容。 How would I do that? 我该怎么做?

You can do one of two things: 您可以执行以下两项操作之一:

  1. Structure the flow of the code so that there is no need for a return statement. 结构化代码流,因此无需return语句。
  2. Place return; 地方return; statements where you want the function to return control to the caller. 您希望函数将控制权返回给调用方的语句。

EDIT: To clarify, return; 编辑: 澄清, return; is a statement that returns control to the caller without yielding a value. 是将控制权返回给调用方而不产生值的语句。

That's basically it. 基本上就是这样。

i think sending a message to nil is a no-op 我认为向nil发送消息是没有操作的

[nil message]

Sending a message to nil? 发送消息为零?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM