Pop quiz!
Will the program below throw an exception when executed?
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
class Review | |
{ | |
public int Score { get; set; } | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var reviews = new List<Review>(); | |
if (reviews.All(r => r.Score < 0)) | |
throw new Exception("Alert manager"); | |
} | |
} |
Now try running it to see the result, you might be surprised 🙂
Not intuitive, now is it.