Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于数组的语法,我觉得这样更好一些 #12

Closed
tomener opened this issue Sep 14, 2022 · 3 comments
Closed

关于数组的语法,我觉得这样更好一些 #12

tomener opened this issue Sep 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@tomener
Copy link

tomener commented Sep 14, 2022

// Declare and initialize
int[] a = [1,2,3]
println(a)

// Declare an empty array and specify the length
int[] b = (4)[];
println(b)

// Append data to array.
a.append(4)
println(a);

@crossoverJie
Copy link
Owner

感谢建议。

  1. 数组定义是用 [] 还是 {},当前我是参考的 Go 使用 {},因为编译器本身是 Go 开发的,所以我个人写起来不会记混,这个只是个人喜好罢了。
  2. append 函数这个其实也是参考的 Go 的语义,不过这也是 Go 被喷的点之一;这个建议不错,后面我调整下。

@crossoverJie crossoverJie added the enhancement New feature or request label Sep 14, 2022
@tomener
Copy link
Author

tomener commented Sep 16, 2022

因为现在大部分语言都是用的**[]**,其它语言转变过来比较易理解,直观,不会有抵触心理。

@crossoverJie
Copy link
Owner

append() 函数已优化,不过数组语法还得考虑一下。
#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants