throwing an exception (that is not caught within the scope).object state modification (that is observable outside of the scope),.variable modification (that is accessible outside of the scope),.“Side effect” is an essential concept that should be reviewed before enumerating the actual transformations.īasically, side effect is any action besides returning a value, that is observable outside of a function or expression scope, like: So, we can rely on “substitution model of recipe application” (by analogy with SICP) to simplify complex expressions. Via seq.exists(_ = x) -> seq.contains(x) Via seq.find(p).isDefined -> seq.exists(p) Via option != None -> option.isDefined Via seq.filter(p).headOption -> seq.find(p) Keep in mind that although all the recipes are isolated and self-contained, we can compose them to iteratively transform more advanced expressions, for example: seq.filter(_ = x).headOption != None
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |