Created
July 17, 2014 12:51
-
-
Save eldewall/017fb3d0589bbfc10493 to your computer and use it in GitHub Desktop.
one-liner vs flera läsbarhet
This file contains 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
// form.Make och form.Models är IEnumerable<string> | |
// one-liner vs flera | |
if (make != null) { | |
form.Makes = new List<string>(form.Makes ?? new List<string>()) { make }; | |
} | |
if (model != null) { | |
if (form.Models == null) { | |
form.Models = new List<string>(); | |
} | |
var models = form.Models.ToList(); | |
models.Add(model); | |
form.Models = models; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment