Questions tagged [mutable]

A mutable can be modified after it is created.

A mutable can be modified after it is created. It is a keyword in functional programming opposite to immutable.

Related tags:

1184 questions
-1
votes
1 answer

Swift set or update asset in core data

Two Entities Gymnast is one to many to Meet I would like to when I save a new meet, it gets assigned to as a meet to each gymnast where they can then score their individuals scores for each event Maybe I completely wrong in my logic, but here is…
debratton
  • 51
  • 1
  • 7
-1
votes
3 answers

Mutable local variable in C++

When I try to create a mutable local variable in C++ I get: error mutable is not allowed during compilation with Visual Studio. does C++ have a some kind of Mutable local variable? is there a better way then const_cost for defining a "non const"…
Aviv A.
  • 697
  • 5
  • 11
-1
votes
1 answer

'Mutating method sent to immutable object error' in Xcode

I am unsure why I get this error when I run my program a certain way. 2014-05-15 16:19:28.932 Puzzle[1002:f803] *** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate:…
user1633930
  • 61
  • 1
  • 2
  • 10
-1
votes
2 answers

why does this happen with lists in python

When I assign one list to another, I see that upon changing one of the elements in one list, the other element is automatically assigned with that value. What is the reason for this behavior? >>> a = [1,2,3] # create a list >>> b = a >>> b [1, 2,…
user2927392
  • 249
  • 3
  • 11
-1
votes
1 answer

Condition for creating a immutable class?

To make a immutable class , Effective Java has one last condition. To make a class immutable, follow these five rules: 5- Ensure exclusive access to any mutable components. If your class has any fields that refer to mutable objects, ensure that…
Thinker
  • 6,820
  • 9
  • 27
  • 54
-1
votes
1 answer

immutable to mutable

How do I wrap an immutable class in a mutable one? For example wrapping Integer and String and create MutableInteger and MutableString. It seems that there are various ways available for doing this. I want to do this with less effort on coding side…
MBZ
  • 26,084
  • 47
  • 114
  • 191
-2
votes
1 answer

Is it possible to write dirty flags with ref getters?

Is it possible to write dirty flags with ref returned get only properties in C#? public class ByRef where T : struct { private bool _dirty; private T _value; public ref T Value { get …
Shadowblitz16
  • 137
  • 2
  • 11
-2
votes
1 answer

strange way of working in DFS in one of leetcode questions

I think this is just about some fundamental difference about Python function and data structure but I wasn't able to figure out why the method II doesn't working it seems the variable res also change values during the traverse but just not as…
xappppp
  • 481
  • 7
  • 18
-2
votes
1 answer

Some puzzles about python mutability and immutablity

I'm confused about the following 3 codes. 1.The first one is intuitive for me util I saw (B): (A) def change (mylist): mylist[0] = 33 mylist[1] = 44 mylist[2] = 55 print("inside the function",mylist) alist =…
-2
votes
4 answers

C++ unordered_map::insert won't compile

I just need a hash map from one float to another. Should be simple, shouldn't it? Compiler just won't accept it: Declaration: unordered_map m_mffPhotoPeakMap; Use: float CProductSpecs::AddToMap(float fEnergy, float returnedValue)…
UserX
  • 485
  • 5
  • 12
-2
votes
1 answer

Accidentally mutating a copy of a struct instead of the struct itself

Having programmed with identity types for years, I find mutating value types very stressful to use due to the constant risk of accidentally assigning (and thus copying) to a new variable and then mutating that copy and expecting to see those changes…
pseudosudo
  • 6,270
  • 9
  • 40
  • 53
-2
votes
2 answers

Python 2.7 - clean syntax for lvalue modification

It is very common to have struct-like types that are not expected to be modified by distant copyholders. A string is a basic example, but that's an easy case because it's excusably immutable -- Python is unusual in even allowing things like method…
personal_cloud
  • 3,943
  • 3
  • 28
  • 38
-2
votes
1 answer

Iterate all inner NSDictionary items and change them?

In my particular case I have NSDictionary object which can contain NSString objects as keys and NSString and NSDictionary objects as values. The inner dictionaries can also contain NSDictionary objects. What if I need to iterate all the inner…
Vyachaslav Gerchicov
  • 2,317
  • 3
  • 23
  • 49
-2
votes
1 answer

How to avoid mutable in this case

Consider this: struct Foo { std::vector x; mutable double* xp; void foo () const { xp = &(x[0]); } }; This wont compile with because of error: invalid conversion from 'const double*' to 'double*' [-fpermissive] The fix is…
463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
-2
votes
5 answers

Creating a Mutable string class in python

I am trying to create a class in python that will have all the str characteristics , but will also be mutable. Example: >>> a = mutableString("My string") >>> print a +"c" "My stringc" >>> a[0] = "a" >>> a "ay string" How is it possible by…
1 2 3
78
79