Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions orleans/BankAccount/AccountTransfer.Grains/AccountGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace AccountTransfer.Grains;

[GenerateSerializer, Immutable]
public record class Balance
[GenerateSerializer]
public class class Balance
{
public int Value { get; init; } = 1_000;
public int Value { get; set; } = 1_000;
}

[Reentrant]
Expand All @@ -21,7 +21,7 @@ public AccountGrain(

public Task Deposit(int amount) =>
_balance.PerformUpdate(
balance => balance with { Value = balance.Value + amount });
balance => balance.Value += amount);

public Task Withdraw(int amount) =>
_balance.PerformUpdate(balance =>
Expand All @@ -34,7 +34,7 @@ public Task Withdraw(int amount) =>
$" This account has {balance.Value} credits.");
}

return balance with { Value = balance.Value + amount };
balance = balance.Value -= amount;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The balance = part here is unnecessary - the balance variable goes out of scope immediately after this statement

});

public Task<int> GetBalance() =>
Expand Down