为什么有时Eclipse的警告在JavaScript中数组的数组? [英] Why does Eclipse sometimes warn about arrays of arrays in JavaScript?

查看:157
本文介绍了为什么有时Eclipse的警告在JavaScript中数组的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中,JavaScript代码以下行

In Eclipse, the following line of JavaScript

var a1 = [[1, 2], [3, 4]];

生成警告:

Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from Number[] to any

,而

var a2 = [['w', 'x'], ['y', 'z']];

生成:

Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from String[] to any

var a3 = [[1, 2], ['y', 'z']];

生成:

Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from String[] to any

然而,这些线路都是好的:

However, these lines are all okay:

var a4 = [[1, 'x'], [3, 'y']];
var a5 = [[1, 2]];
var a6 = [['x', 'y']];

有似乎与数组的数组,当子阵列包含相同基本类型的问题。不过,我不明白为什么,和code似乎执行好。有人可以解释什么是Eclipse担心什么?

There seems to be a problem with arrays of arrays, when the sub-arrays contain the same primitive type. However, I don't understand why, and the code seems to execute okay. Can someone explain what Eclipse is worried about?

推荐答案

它看起来像一个错误。有本质上是在JavaScript类型不匹配没有这样的事情。

It looks like a bug. There is essentially no such thing as a type mismatch in Javascript.

我会大胆地猜测说是这样做的解析器是基于一个Java解析器,这是有点那个原来的解析器偷看的。

I would hazard a guess that the parser that is doing this was based on a Java parser, and this is a bit of that original parser peeking through.

这篇关于为什么有时Eclipse的警告在JavaScript中数组的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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