File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
Assets/JCSUnity/Scripts/Util Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change 77 * Copyright (c) 2017 by Shen, Jen-Chieh $
88 */
99using System . Collections . Generic ;
10+ using System . Linq ;
1011using UnityEngine ;
1112
1213namespace JCSUnity
@@ -91,23 +92,18 @@ private static float FindDecimalInclude(float num)
9192 /// <typeparam name="T"> Type of the object. </typeparam>
9293 /// <param name="inArray"> The list or array to choose from. </param>
9394 /// <returns> The chosen object from the list or array. </returns>
94- public static T ChooseOne < T > ( T [ ] inArray )
95+ public static T ChooseOneE < T > ( params T [ ] args ) // Ellipsis
9596 {
96- if ( inArray . Length == 0 ) return default ( T ) ;
97- int index = Range ( 0 , inArray . Length ) ;
98- return inArray [ index ] ;
97+ return ChooseOne ( args ) ;
9998 }
100- public static T ChooseOne < T > ( List < T > inList )
99+ public static T ChooseOne < T > ( ICollection < T > inList )
101100 {
102- if ( inList . Count == 0 ) return default ( T ) ;
101+ if ( inList . Count == 0 )
102+ return default ( T ) ;
103+
103104 int index = Range ( 0 , inList . Count ) ;
104- return inList [ index ] ;
105- }
106- public static T ChooseOneE < T > ( params T [ ] args ) // Ellipsis
107- {
108- if ( args . Length == 0 ) return default ( T ) ;
109- int index = Range ( 0 , args . Length ) ;
110- return args [ index ] ;
105+
106+ return inList . ElementAt ( index ) ;
111107 }
112108
113109 /// <summary>
You can’t perform that action at this time.
0 commit comments