{"id":2610,"date":"2015-09-16T00:54:37","date_gmt":"2015-09-16T00:54:37","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2610"},"modified":"2015-09-16T00:54:37","modified_gmt":"2015-09-16T00:54:37","slug":"scala-exists-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-exists-example\/","title":{"rendered":"Scala exists example"},"content":{"rendered":"<p>The &#8220;exists&#8221; method checks to see if a value is in a list of values:<\/p>\n<pre lang=\"scala\">\nRange(1, 10).\n  exists(\n    x => x.equals(2)\n  )\n<\/pre>\n<p>If you make the list into a view, &#8220;exists&#8221; will only load items from the view until it finds a value, as seen here:<\/p>\n<pre lang=\"scala\">\nRange(1, 10).\n  view.\n  map(x => \n   if (x < 5) x else ???\n  ).\n  exists(\n    x => x.equals(2)\n  )\n<\/pre>\n<p>You can also simplify this and check for values like &#8220;None&#8221;:<\/p>\n<pre lang=\"scala\">\nList(1, 2, None).exists(_.equals(None))\n\nres155: Boolean = true\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The &#8220;exists&#8221; method checks to see if a value is in a list of values: Range(1, 10). exists( x => x.equals(2) ) If you make the list into a view, &#8220;exists&#8221; will only load items from the view until it finds a value, as seen here: Range(1, 10). view. map(x => if (x < 5) &hellip; \n\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/scala-exists-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Scala exists example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[480,482],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2610"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2610"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2610\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}