immutability Questions
3
Solved
Conventional way of dealing with optional list arguments is the following:
def func(list_of_vals = None):
if list_of_vals is None:
list_of_vals = []
...
I wounder if the following (shorter) v...
Climax asked 28/10, 2016 at 21:36
10
It is possible to create a DeepReadonly type like this:
type DeepReadonly<T> = {
readonly [P in keyof T]: DeepReadonly<T[P]>;
};
interface A {
B: { C: number; };
D: { E: number; }[...
Inconsequent asked 26/1, 2017 at 17:23
2
Solved
Assume that I have the following mutable class:
class Foo {
constructor(public bar: any) { }
}
I can define readonly instances of this class like so:
const foo: Readonly<Foo> = new Foo(1...
Insusceptible asked 27/5, 2020 at 7:59
6
Solved
Why should objects in Redux be immutable?
I know that some frameworks such as Angular2 will use onPush and can take advantage of immutability to compare states of views for faster rendering, but I ...
Proteus asked 23/1, 2016 at 2:1
6
I have several classes that are immutable once their initial values are set. Eric Lippert calls this write-once immutability.
Implementing write-once immutability in C# usually means setting the i...
Nw asked 18/8, 2009 at 14:35
3
Solved
I've been looking at the readonly type in typescript. Sadly, it does not work as i hope it would. For instance, see the code below:
interface User{
firstName: string;
lastName: string;
}
const ...
Inimitable asked 21/11, 2018 at 13:17
14
Solved
A frozen set is a frozenset.
A frozen list could be a tuple.
What would a frozen dict be? An immutable, hashable dict.
I guess it could be something like collections.namedtuple, but that is m...
Fahlband asked 24/4, 2010 at 7:19
4
Solved
I've done some searching and found that JavaScript objects can be frozen or sealed, meaning that they cannot be modified or have new properties added to them, respectively.
I understand what these ...
Masters asked 9/12, 2022 at 0:49
2
Solved
Kotlin has a const-keyword. But I don't think constants in kotlin are what I think they are. It seems to very different to const in C++. It seems to me that its is only available for static members...
Schoolgirl asked 24/8, 2019 at 7:45
2
I'm new to ngrx (and never used redux) and am trying to make sense of it all - especially whether you need deep copies of the state. Here's what I've learned so far and what still confuses me (furt...
Quilmes asked 3/1, 2020 at 11:34
16
Solved
I seem to be having issues pushing data into a state array.
I am trying to achieve it this way:
this.setState({ myArray: this.state.myArray.push('new value') })
But I believe this is incorrect w...
Foamflower asked 25/5, 2016 at 11:8
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Tyus asked 22/6, 2013 at 2:15
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Renounce asked 22/6, 2013 at 2:15
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Rees asked 22/6, 2013 at 2:15
14
It is not clear to me when anyone would need to use Object.freeze in JavaScript. MDN and MSDN don't give real life examples when it is useful.
I get it that an attempt to change such an object at r...
Insurer asked 9/2, 2013 at 20:35
4
Solved
I need an immutable list where I can get derive a second immutable list preserving all elements of the previous list plus an additional element in Java (without additional libraries).
Note: This q...
Charters asked 21/7, 2021 at 21:53
14
Solved
I am currently working on React JS and React Native frameworks. On the half way road I came across Immutability or the Immutable-JS library, when I was reading about Facebook's Flux and Redux imple...
Fbi asked 20/12, 2015 at 20:0
6
Solved
What tools or libraries exists for Java that will take an interface only with accessor method definitions and automatically generate an immutable object class and also a "builder" class for increme...
Monitory asked 6/2, 2013 at 9:43
20
I'm confused on what an immutable type is. I know the float object is considered to be immutable, with this type of example from my book:
class RoundFloat(float):
def __new__(cls, val):
return f...
Joletta asked 8/11, 2011 at 19:41
1
Structs are immutable meaning that they can't change. I must clearly misunderstand this whole concept as it seems that sometimes I do get to change the struct, and othertimes I don't.
Conside...
Warrigal asked 26/12, 2023 at 21:34
12
Solved
Just curious: In Kotlin, I would love to get some val that can be initialized by lazy, but with a parameter. That's because I need something that's created very late in order to initialize it.
Spe...
Subduct asked 25/1, 2018 at 12:41
27
Solved
I'm trying to remove specific characters from a string using Python. This is the code I'm using right now. Unfortunately, it appears to do nothing to the string.
for char in line:
if char in "...
Comparison asked 15/10, 2010 at 3:46
9
Solved
I would like to write something like this:
var d = new ImmutableDictionary<string, int> { { "a", 1 }, { "b", 2 } };
(using ImmutableDictionary from System.Collections.Immutable). It seems ...
Trying asked 4/6, 2014 at 9:22
5
Solved
A few times, I've run into the scenario where an accessor method is needed for both mutable and immutable references.
For ~3 lines it isn't a problem to duplicate the logic, but when the logic get...
Alembic asked 3/1, 2017 at 4:40
9
Solved
Does python have immutable lists?
Suppose I wish to have the functionality of an ordered collection of elements, but which I want to guarantee will not change, how can this be implemented? Lists a...
Suomi asked 21/6, 2012 at 16:15
1 Next >
© 2022 - 2024 — McMap. All rights reserved.