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
0
votes
1 answer

Kind of mutable image in iOS?

I am searching for a image class which is mutable. As you know NSArray is not mutable and NSMutableArray is mutable. Apple Documentation about UIImage Image objects are immutable, so you cannot change their properties after creation. What I…
Studie
  • 799
  • 2
  • 12
  • 20
0
votes
4 answers

How can I ensure that every child class gets a fresh copy of its parent's class attributes (in Python)?

I have a base class which has a blank list as a class attribute. Many child classes inherit from this base class. The intent is to use this list class attribute in conjunction with a class method in order to allow each child class to keep track of a…
tel
  • 13,005
  • 2
  • 44
  • 62
0
votes
3 answers

Looking for NSMutableDate class

Is there such third-party extension of NSDate? I need some methods to adjust date (increase or decrease day/month/year) and keep the date object in the same memory (so myDate = getNewDateByAdjustingOldOne (myDate); would not be acceptable). If there…
brigadir
  • 6,874
  • 6
  • 46
  • 81
0
votes
2 answers

Images in array, HOW TO?

I made 26 buttons, A-Z and when I click them the image of the button I pressed will display in an image view, when I click A, it displays A, When I click B it will display B etc. The problem I have is that they won't display next to each other, I…
Don Kooijman
  • 593
  • 1
  • 4
  • 13
0
votes
1 answer

linked list MutableString homework inheriting vs delegation

I have a linked list question that stems from this homework prompt I am about to post. it might help with the answer: Specifics The Java String class is immutable (you cannot change the contents). This is sometimes a hindrance to what you want to…
anthony
  • 71
  • 8
-1
votes
2 answers

This example subverts my understanding of ownership and reference scope

// print: // string-a // string-aaabc fn main() { let mut a = String::from("string-"); let s = &mut a; let ss = &mut a; // s goes out of scope here ss.push('a'); // string-a println!("{}", ss.clone()); //…
杨尚山
  • 1
  • 1
-1
votes
1 answer

Avoid "$0' is immutable" on a lazy getter function?

I have a lazy var in my struct called labelColors: lazy var _labelColors: LabelType = { return url.getTagColors() }() var labelColors : LabelType { mutating get { return _labelColors } set { _labelColors = newValue…
Peter71
  • 2,180
  • 4
  • 20
  • 33
-1
votes
1 answer

How do i change Python 2d array elements?

new = [] curvepoints = [] for i in range (0, 10): for j in range (0, 3): new.append(0) curvepoints.append(new) new = [] I have initialized my main array curvepoints using the above code p = [-30, -23, -16, -9, -2, 5, 12,…
-1
votes
1 answer

Rust pushing to vector with borrow_mut

Let's have a struct containing a vector of cities and a new_city function adding City to the vector. However, I got BorrowMutError which makes sense. What should I do so I can call new_city multiple times (see below)? I would need to drop the…
-1
votes
2 answers

Composable function not being executed after mutable value change

So I got this line of code: fun LiveTrainingScreen(viewModel: LiveTrainingViewModel = viewModel()) { Column(modifier = Modifier.padding(PaddingStatic.Small).zIndex(2f)) { //Large Video Display //here var videoLink = remember {…
-1
votes
1 answer

Rust How to modify a polars DataFrame in a function, so that the caller see the changes?

I am lost at the mutable references ... Trying to send a DataFrame into a function ... change it and see the changes after the function call completes ... I get error: cannot borrow as mutable Here is a code sample: use polars::prelude::*; use…
Robert
  • 131
  • 1
  • 7
-1
votes
1 answer

Why cannot I modify individual list items?

In the following program, I am unable to modify individual list items: public class Program { static void Main(string[] args) { List list = new List(); list.Add(new Point2d(0, 0)); list.Add(new…
user366312
  • 16,949
  • 65
  • 235
  • 452
-1
votes
2 answers

Is there any way to make the method return a mutable value?

as shown in the code below: struct Person { var name: String } struct Group { var person: Person func callAsFunction() -> Person { // Person is immutable value person } } var james = Person(name: "James") var…
hopy
  • 559
  • 3
  • 18
-1
votes
2 answers

Python mutable object concatenation to list

I have these lines of code and I don't understand why does it work. list_ = [] string = '12345' for i in string: list_ += i print(list_) #Output: ['1', '2', '3', '4', '5'] People say this is the magic of python and I have this link below, but I…
Benku BBB
  • 1
  • 3
-1
votes
1 answer

cannot borrow `s` as immutable because it is also borrowed as mutable

I'm having trouble with immutable borrow problem. immutable borrow occurs in "println!("{} ", s); " , but later I don't use the immutable borrow value any more. I have: fn main() { let mut s = String::from("hello"); let r3 = &mut s; …
yhj050806
  • 19
  • 1