很简单:找出数组的元素是否存在 [英] Very simple: Find out if element of array exists

查看:75
本文介绍了很简单:找出数组的元素是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想做一些看似简单的事情:找出传递给我的函数的数组中是否存在

元素。


我以前认为我可以做:if(arr [i])...

但是,如果这个元素的价值发生了为0,条件

将返回false,即使元素实际存在。


有什么想法吗?你能检查一下元素== null吗?


- Noah

解决方案

Noah Spitzer-Williams写道:

大家好,

我想做一些看似简单的事情:找出传递给我的函数的数组中的
元素是否存在。




你不能将数组传递给函数。


数组中的所有元素都存在。


我不明白这个问题。


-Kevin

-

我的电子邮件地址是有效的,但会定期更改。

要联系我,请使用最近发布的地址。


2003年9月23日19:10:57 -0700, no****@cyberdude.com (Noah Spitzer-Williams)写道:

我想做一些看似简单的事情:找出传递给m的数组中的
元素y函数存在。




确实非常简单:数组的所有元素都存在。


< blockquote> 2003年9月24日星期三02:14:30 GMT,Kevin Goodsell< us ********************* @ neverbox.com>写道:

Noah Spitzer-Williams写道:

大家好,

我想做一些看似简单的事情:找出来如果存在传递给我的函数的数组中的
元素。
你不能将数组传递给函数。




是吗讽刺?


数组中的所有元素都存在。

我不明白这个问题。




美国在线。


Hello guys,

I would like to do something seemingly simple: find out if an
element in an array that is passed to my function exists.

I used to think I could just do: if (arr[i]) ...
However, if this element''s value happens to be 0, the conditional
will return false, even though the element actually exists.

Any ideas? Can you check if the element == null?

- Noah

解决方案

Noah Spitzer-Williams wrote:

Hello guys,

I would like to do something seemingly simple: find out if an
element in an array that is passed to my function exists.



You can''t pass arrays to functions.

All elements in an array exist.

I don''t understand the question.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


On 23 Sep 2003 19:10:57 -0700, no****@cyberdude.com (Noah Spitzer-Williams) wrote:

I would like to do something seemingly simple: find out if an
element in an array that is passed to my function exists.



That is very simple indeed: all elements of an array exist.


On Wed, 24 Sep 2003 02:14:30 GMT, Kevin Goodsell <us*********************@neverbox.com> wrote:

Noah Spitzer-Williams wrote:

Hello guys,

I would like to do something seemingly simple: find out if an
element in an array that is passed to my function exists.
You can''t pass arrays to functions.



Is that irony?

All elements in an array exist.

I don''t understand the question.



AOL.


这篇关于很简单:找出数组的元素是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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