Kotlin“预期变量”给数组元素赋值时出错

发布于 2025-01-16 12:20:14 字数 353 浏览 1 评论 0原文

我正在编写以下嵌套函数,其中 dfsVisit 使用外部函数中声明的数组“numCaminos”和“colores” 在此处输入图像描述

但是,kotlin 编译器在第 31 行和第 34 行的赋值上给出了“预期变量”错误,此错误不会出现在嵌套 dfsVisit 函数内的任何其他数组赋值上。我尝试解除函数的嵌套并将数组作为 dfsVisit 的参数传递,但问题在这两个分配上仍然存在。为什么会发生这种情况?

我通过存储库包在 Manjaro Linux 中运行 Kotlin 编译器

注意:很抱歉使用图片而不是代码块,帖子编辑器给了我一些格式问题。

I'm writing the following nested function where dfsVisit uses the arrays "numCaminos" and "colores" declared in the outer function
enter image description here

However the kotlin compiler is giving me a "variable expected" error on the assignments in lines 31 and 34 specifically, this error doesn't show up on any of the other Array assignments within the nested dfsVisit function. I tried de-nesting the functions and passing the arrays as arguments of dfsVisit but the problem persisted on those 2 assignments specifically. Why could this be happening?

I'm running the Kotlin compiler in Manjaro Linux through the repository package

Note: Sorry for using a picture instead of a code block, the post editor was giving me some formatting issues.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熟人话多 2025-01-23 12:20:14

只需从作业的左侧删除 !! 即可。那里确实没有意义。

Just remove !! from the left side of the assignment. It doesn't really make sense there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文