immutability Questions
5
Solved
I came across a problem that required iterating over an array in pairs. What's the best way to do this? Or, as an alternative, what's the best way of transforming an Array into an Array of pairs (w...
Bugaboo asked 28/11, 2016 at 10:10
2
Solved
In D, how do I declare an either const or immutable pointer to non-const / mutable data in D?
The dlang website says you can't just declare it as const, as this makes both the pointer const and th...
Xylia asked 6/7, 2016 at 4:35
2
Solved
I was solving some exercises to get some practice in go and came across the
following problem.
Take this function:
func foo(s string) {
length := len(s);
// Do something just reading from lenght...
Marquisette asked 21/6, 2021 at 21:45
14
Solved
How can one make a Java class immutable, what is the need of immutability and is there any advantage to using this?
Shinar asked 2/7, 2010 at 1:5
3
Solved
Is it possible to rerender an element of an array, preventing others rerender?
Example: Having an array of 500 <Card> components and editing <Card> number 27 (which updates myArray pro...
Cutting asked 19/9, 2019 at 16:39
1
Solved
Using Spring Data JPA with Hibernate, are these two annotations interchangeable?
org.hibernate.annotations.Immutable
org.springframework.data.annotation.Immutable
More specifically, can the Sprin...
Hg asked 24/5, 2021 at 22:35
3
var a = ImmutableList<int>.Empty.Add(1).Add(2).Add(3);
var b = ImmutableList<int>.Empty.Add(1).Add(2).Add(3);
Console.WriteLine(a.Equals(b)); // False
In the code above the a.Equals(...
Passmore asked 12/3, 2016 at 19:8
1
Solved
Java records are used to implement shallowly immutable data carrier types. If the constructor accepts mutable types then we should implement explicit defensive copying to enforce immutability. e.g....
Illnatured asked 19/5, 2021 at 13:18
1
Solved
Is there a standard way in Kotlin to associate a new key-value pair with an immutable map?
// => {A=1, B=2, C=3}
associate(mapOf("A" to 1, "B" to 2), "C", 3);
Thin...
Colorfast asked 19/5, 2021 at 8:52
4
Solved
Why would the map method mutate the original array when its initial purpose is to create a new array ?
I have an array of object which I pass to a pure function which in turn maps the given array...
Moyra asked 11/1, 2016 at 8:4
11
Solved
From the Collections Framework Overview:
Collections that do not support modification operations (such as add, remove and clear) are referred to as unmodifiable. Collections that are not ...
Parasol asked 17/1, 2012 at 9:39
7
Solved
According to MDN Object.freeze() documentation:
The Object.freeze() method freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being rem...
Blooming asked 20/1, 2016 at 18:4
4
Solved
What is meant by immutable type and immutable property in C# ? can you give simple example?
Trochelminth asked 29/3, 2010 at 11:56
8
Solved
I need to convert mutable list object to immutable list. What is the possible way in java?
public void action() {
List<MutableClass> mutableList = Arrays.asList(new MutableClass("san", "UK"...
Zadazadack asked 20/5, 2015 at 11:26
1
Solved
Raku provides many types that are immutable and thus cannot be modified after they are created. Until I started looking into this area recently, my understanding was that these Types were not persi...
Medrano asked 10/4, 2021 at 3:12
4
Solved
Ok, so I'm so frustrated finding the right solution so I'm posting the problem here. Giving an answer would help me a lot, coz I'm stuck!
the state tree looks like this
this.state = {
itemList ...
Subcritical asked 25/3, 2018 at 15:32
2
Solved
I have a Java/Kotlin interop problem. A Kotlin immutable list is compiled into a normal java.util.ArrayList that is mutable!
Kotlin (library):
class A {
val items: List<Item> = ArrayList()...
Prakash asked 12/11, 2016 at 15:43
5
Solved
I have following reducer code in my react-redux app:
case 'TOGGLE_CLIENT_SELECTION':
const id = action.payload.id;
let newState = Object.assign({}, state);
newState.list.forEach((client) =>...
Frap asked 28/3, 2017 at 15:51
5
Solved
I know Integers are immutable in Java. But why it is designed this way?
I went through other answers before asking this question:
Is Integer Immutable
i++ still working for immutable Integer in ...
Yellowlegs asked 1/4, 2014 at 18:11
16
Solved
We all know that String is immutable in Java, but check the following code:
String s1 = "Hello World";
String s2 = "Hello World";
String s3 = s1.substring(6);
System.out.println(s1); // Hello W...
Experience asked 6/1, 2014 at 7:26
1
Solved
I'm trying to implement the Index method for a struct with interior mutability:
pub struct FooVec {
foo: RefCell<Vec<i32>>
}
impl Index<usize> for FooVec {
type Output = i32;
...
Corroboration asked 5/3, 2021 at 14:36
12
Solved
I know this is probably very stupid, but a lot of places claim that the Integer class in Java is immutable, yet the following code:
Integer a=3;
Integer b=3;
a+=b;
System.out.println(a);
Execute...
Malissamalissia asked 6/4, 2011 at 0:27
16
Solved
My goal is to make a Java object immutable. I have a class Student. I coded it in the following way to achieve immutability:
public final class Student {
private String name;
private String age;
...
Vagrant asked 12/8, 2013 at 18:33
5
Solved
I came across this exercise online where I have two classes and I'm supposed to make the Tutor class immutable. However, the only thing I can think of is adding final to name field. When it comes t...
Primipara asked 9/5, 2018 at 15:44
7
Solved
Is it a good idea to create objects that cannot be changed in PHP?
For example a date object which has setter methods, but they will always return a new instance of the object (with the modified d...
Justino asked 20/1, 2013 at 17:16
© 2022 - 2024 — McMap. All rights reserved.