Skip to content

Commit 41866b8

Browse files
committed
Add function setItem
1 parent a5281cc commit 41866b8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/FSharpPlus/Operators.fs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ namespace FSharpPlus
33
open System
44
open FSharpPlus.Control
55

6+
#nowarn "0077" // Member constraints with the name 'set_Item' ...
7+
68
/// Generic functions and operators
79
[<AutoOpenAttribute>]
810
module Operators =
@@ -858,6 +860,17 @@ module Operators =
858860
/// <category index="16">Indexable</category>
859861
let inline tryItem (n: 'K) (source: '``Indexed<'T>``) : 'T option = TryItem.Invoke n source
860862

863+
/// <summary>
864+
/// Mutates an item at the given key/index.
865+
/// </summary>
866+
/// <param name="item">The key/index where to set the value.</param>
867+
/// <param name="value">The value to set.</param>
868+
/// <param name="source">The input collection.</param>
869+
/// <returns>unit</returns>
870+
/// <remarks>This function requires that the source type has a mutable indexer.</remarks>
871+
/// <category index="16">Indexable</category>
872+
let inline setItem (item: 'K) (value: 'T) (source: ^``Indexed<'T>``) = (^``Indexed<'T>`` : (member set_Item : 'K -> 'T -> unit) (source, item, value))
873+
861874
/// <summary>
862875
/// Maps with access to the index.
863876
/// </summary>

0 commit comments

Comments
 (0)