Created
December 16, 2018 12:17
-
-
Save MarcBruins/b91a35f5bfe767aeba22c4243c790542 to your computer and use it in GitHub Desktop.
Fixing returning null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2) | |
{ | |
if (HasElements(list1)) | |
return list1; | |
if (HasElements(list2)) | |
return list2; | |
return new List<string>(); | |
} | |
//OR | |
public static IReadOnlyCollection<string>? FirstPopulatedList(List<string> list1, List<string> list2) | |
{ | |
if (HasElements(list1)) | |
return list1; | |
if (HasElements(list2)) | |
return list2; | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment