Skip to content

Commit

Permalink
Add TryItem functionality to FsColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Aug 11, 2023
1 parent 5c2e616 commit 3e7b7d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/FsSpreadsheet/FsColumn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ type FsColumn (rangeAddress : FsRangeAddress, cells : FsCellsCollection)=
static member item rowIndex (column : FsColumn) =
column.Item(rowIndex)

/// <summary>
/// Returns the FsCell at the given rowIndex if it exists. Else returns None.
/// </summary>
/// <param name="rowIndex">The number of the column where the FsCell shall be retrieved.</param>
member this.TryItem(rowIndex) =
if this.HasCellAt rowIndex then Some this[rowIndex]
else None

/// <summary>
/// Returns the FsCell at the given rowIndex if it exists in the given FsColumn. Else returns None.
/// </summary>
/// <param name="rowIndex">The number of the column where the FsCell shall be retrieved.</param>
static member tryItem rowIndex (column: FsColumn) =
column.TryItem rowIndex

///// <summary>
///// Inserts the value at columnIndex as an FsCell. If there is an FsCell at the position, this FsCells and all the ones /right /to it are shifted to the right.
///// </summary>
Expand Down

0 comments on commit 3e7b7d2

Please sign in to comment.