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

[Docs] Show inline array value initialiser shortcut #1660

Closed
Honga1 opened this issue Dec 20, 2021 · 1 comment · Fixed by #1661
Closed

[Docs] Show inline array value initialiser shortcut #1660

Honga1 opened this issue Dec 20, 2021 · 1 comment · Fixed by #1661
Assignees
Labels
part: documentation Dafny's reference manual, tutorial, and other materials

Comments

@Honga1
Copy link

Honga1 commented Dec 20, 2021

What

Add inline array intialiser syntax to documentation

// This
var a := new int[] [1, 2, 3, 4];
// is better than
var a := new int[4];
a[0], a[1], a[2], a[3] := 1, 2, 3 , 4;

Why

This is an expected feature from the use in other languages such as c#. It should feel more obvious.

Background

I was trying to find a way to initialise an array to a list of values. I could not find this in the docs easily (cheatsheet, tutorial, quick reference). Except for doing it in spread assignment fashion.

I then found this PR which introduced the feature. However it seems it's undocumented:

72f60ac

Edit: I can see the syntax listed here:
https://dafny-lang.github.io/dafny/DafnyRef/DafnyRef#151-one-dimensional-arrays

@Honga1 Honga1 changed the title [Documentation] Show inline array value initialiser shortcut in docs [Docs] Show inline array value initialiser shortcut in docs Dec 20, 2021
@Honga1 Honga1 changed the title [Docs] Show inline array value initialiser shortcut in docs [Docs] Show inline array value initialiser shortcut Dec 20, 2021
@keyboardDrummer keyboardDrummer added the part: documentation Dafny's reference manual, tutorial, and other materials label Dec 20, 2021
@MikaelMayer MikaelMayer self-assigned this Dec 20, 2021
@MikaelMayer
Copy link
Member

That was an easy fix, thanks for reporting ! Will be resolved with #1661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: documentation Dafny's reference manual, tutorial, and other materials
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants