{"id":2617,"date":"2015-09-16T01:03:40","date_gmt":"2015-09-16T01:03:40","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2617"},"modified":"2015-09-16T01:03:40","modified_gmt":"2015-09-16T01:03:40","slug":"scala-take-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-take-example\/","title":{"rendered":"Scala take example"},"content":{"rendered":"<p>The &#8220;take&#8221; method lets you pull a few items from a list:<\/p>\n<pre lang=\"scala\">\nList(1, 2, 3, 4, 5).take(3)\n\nres6: List[Int] = List(1, 2, 3)\n<\/pre>\n<p>If you want to pull these from the other end of the list, you can use takeRight:<\/p>\n<pre lang=\"scala\">\nList(1, 2, 3, 4, 5).takeRight(3)\n\nres8: List[Int] = List(3, 4, 5)\n<\/pre>\n<p>Similarly, you can use &#8220;takeWhile&#8221; to pull items until a condition is met:<\/p>\n<pre lang=\"scala\">\nStream.\n  from(1).\n  takeWhile(_ < 5).\n  toList\n\nres6: List[Int] = List(1, 2, 3)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The &#8220;take&#8221; method lets you pull a few items from a list: List(1, 2, 3, 4, 5).take(3) res6: List[Int] = List(1, 2, 3) If you want to pull these from the other end of the list, you can use takeRight: List(1, 2, 3, 4, 5).takeRight(3) res8: List[Int] = List(3, 4, 5) Similarly, you can use &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/scala-take-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Scala take 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,488],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2617"}],"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=2617"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2617\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}