常规编程-调用非void方法但不使用值 [英] General programming - calling a non void method but not using value

查看:68
本文介绍了常规编程-调用非void方法但不使用值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是常规编程,但是如果有所作为,我使用的是Objective-C.假设有一个返回值的方法,该方法还执行一些操作,但是您并不关心它返回的值,而只关心它返回的值.您会像调用该方法一样将其视为无效方法吗?还是将结果放入变量中,然后将其删除或忘记呢?陈述您的意见,遇到这种情况该怎么办.

This is general programming, but if it makes a difference, I'm using objective-c. Suppose there's a method that returns a value, and also performs some actions, but you don't care about the value it returns, only the stuff that it does. Would you just call the method as if it was void? Or place the result in a variable and then delete it or forget about it? State your opinion, what you would do if you had this situation.

推荐答案

一个常见的例子是printf,它返回一个int ...,但是您很少看到:

A common example of this is printf, which returns an int... but you rarely see this:

int val = printf("Hello World");

这篇关于常规编程-调用非void方法但不使用值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆