Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

[2.6.2] Array of structures is not initialized on creation #420

Closed
JechoJekov opened this issue May 28, 2015 · 2 comments
Closed

[2.6.2] Array of structures is not initialized on creation #420

JechoJekov opened this issue May 28, 2015 · 2 comments

Comments

@JechoJekov
Copy link

Saltarelle compiler does not initialize array of structures when the array is created which is unexpected and different from the behavior of the .NET Framework.

The following code:

var p = new int[3];
((dynamic)System.Html.Window.Instance).console.log(p[0]);

displays "undefined".

This behavior has obvious performance consequences. However, IMO it should be document at some obvious place since it is unexpected.

Workaround: Use "Array.Repeat" to create an array.

@erik-kallen
Copy link
Contributor

Yes, I will look at this in v3.

@geoffreymcgill
Copy link
Member

Looks like this sample is returning the correct result in Bridge.

http://deck.net/ec79cb23323df25d369729dc5eecf471

public class Program
{
    public static void Main()
    {
        var p = new int[3];
        
        Console.WriteLine(p[0]);
    }
}

Hope this helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants