Questions tagged [immutablearray]
11 questions
19
votes
2 answers
What is ImmutableArray in c#
I see this:
This packages provides collections that are thread safe and guaranteed
to never change their contents, also known as immutable collections.
But i dont understand what is exactly and when we should use ImmutableArray?
Edit: nowadays,…
user1968030
9
votes
1 answer
static ImmutableArray is not initialized
I have one internal static class MyLists with a static member:
internal static ImmutableArray MyList =
new ImmutableArray { "asd", "qwe" };
In another public test class Tests I have a MyTest function which selects and compares…

ditoslav
- 4,563
- 10
- 47
- 79
3
votes
1 answer
System.MissingMethodException is thrown when calling a Method with ImmutableArray<> on an interface in a different dll
Problem
I have the below code in the two respective dlls. dll1 depends on dll2.
When DoWork() is called it will execute myInterface.MyListMethod(ImmutableList.Empty); fine. When it goes to execute…

Skyler Jokiel
- 318
- 2
- 11
3
votes
0 answers
Why does using static field of type ImmutableArray in struct cause TypeLoadException
I'm attempting to use a static field of type ImmutableArray in a struct where T is the type of the struct. However, when I attempt to do this, I get an immediate TypeLoadException when I execute the program. This appears to occur before the…

Mike Cowan
- 919
- 5
- 11
2
votes
2 answers
What is the difference between ImmutableArray.As and ImmutableArray.CastArray methods?
I'm trying to understand the exact difference between the 3 following methods of the ImmutableArray struct:
the static method ImmutableArray.CastUp
the instance method ImmutableArray.As
the instance method…

Enrico Massone
- 6,464
- 1
- 28
- 56
2
votes
2 answers
Mutable array of immutable length in D
Is it possible in D to have a mutable array of which the length is not known at compile time to have a static length?
void testf(size_t size) {
int immutable([]) testv = new int[](a);
}

Jeroen
- 15,257
- 12
- 59
- 102
1
vote
3 answers
Potential uses of an empty tuple in Python
I was playing around with the risks of class-level variables in Python, and I thought that the risk of lists as class-level variables can be solved with tuples, for example, an empty tuple.
Take:
class BaseClass(object):
default_sth = []
…

jleeothon
- 2,907
- 4
- 19
- 35
0
votes
2 answers
Append strings to array with Immutable
Having as Input a list of String (one of them could be None). How can I return a Array of String using Immutable Object.
It's pretty easy if I use var or Mutable Object, here an example:
def getArrayString(string: String, list1: List[String], list2:…

salvob
- 1,300
- 3
- 21
- 41
0
votes
1 answer
Cannot assign to immutable expression of type ' AnyObject?!'
I did some search but still cannot figure out how to solve the error.
Basically I am reading booklist from Json file and then update it. The reading part is fine but error ("Cannot assign to immutable expression of type ' AnyObject?!'") happens when…

Adaoli
- 27
- 1
- 5
0
votes
2 answers
How to create an immutable associative array in D
Is there a way to create an immutable associative array in D? There doesn't seem to be a way to define an associative array; only declare one.
immutable char[][char[]] = ["testk" = "testv", "testk2" = "testv2"];

Jeroen
- 15,257
- 12
- 59
- 102
-4
votes
1 answer
Pros and cons of creating immutable empty array in swift
I am new to Swift Programming language. I am learning it from Apple's site. I came across below line of code:
let emptyArray = [String]()
I have asked another question related to this but not completely. I want to know that what are the pros and…

Priyank Sheth
- 2,352
- 19
- 32