Skip to content

Commit 682c830

Browse files
authored
DYN-7082: Adding a new node List.StringifyIndexOf (#15440)
1 parent c7cea26 commit 682c830

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Libraries/CoreNodes/List.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,17 @@ public static IList SetUnion(IList<object> list1, IList<object> list2)
161161
}
162162

163163
/// <summary>
164-
/// Returns the index of the element in the given list. Match between given list and target element must be a strict match (i.e. int to int, double to double, string to string, object to object etc.)
164+
/// Returns the index of the element in the given list. Match between given list and target element must be a strict match (i.e. int to int, double to double, string to string, object to object etc.).
165165
/// </summary>
166166
/// <param name="list">The list to find the element in.</param>
167167
/// <param name="element">The element whose index is to be returned.</param>
168168
/// <returns name="int">The index of the element in the list. Invalid index -1 will be returned if strict match not found.</returns>
169169
/// <search>index,indexof</search>
170170
[IsVisibleInDynamoLibrary(true)]
171-
public static int IndexOf(IList list, object element)
171+
public static int? IndexOf(IList list, object element)
172172
{
173-
return list.IndexOf(element);
173+
var index = list.IndexOf(element);
174+
return index < 0 ? null : index;
174175
}
175176

176177
/// <summary>

test/Libraries/CoreNodesTests/ListTests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using Dynamo.Graph.Nodes;
65
using NUnit.Framework;
76
using List = DSCore.List;
87

@@ -180,7 +179,7 @@ public static void ListSetUnion()
180179
public static void ListIndexOf()
181180
{
182181
Assert.AreEqual(1, List.IndexOf(new ArrayList { "x", "y", 1 }, "y"));
183-
Assert.AreEqual(-1, List.IndexOf(new ArrayList { 3, 4, 6, 8 }, 9));
182+
Assert.AreEqual(null, List.IndexOf(new ArrayList { 3, 4, 6, 8 }, 9));
184183
}
185184

186185
[Test]

0 commit comments

Comments
 (0)