{"blog_title":"Scala\u65e5\u8a18","description":"val opts: Seq[Option[Int]] = Seq(Some(2), None, Some(3)) \u306e\u3088\u3046\u306a\u3082\u306e\u304b\u3089\u5024\u306e\u3042\u308b\u3082\u306e\u3060\u3051\u3092\u53d6\u308a\u51fa\u3057\u3066\u3001 List(2, 3) \u3092\u4f5c\u308a\u305f\u3044\u3068\u304d\u306b\u3001Scala\u3092\u899a\u3048\u305f\u3066\u306e\u9803\u306f\u3084\u308a\u65b9\u304c\u3088\u304f\u5206\u304b\u3089\u306a\u304f\u3066\u3001\u6700\u521d\u306b\u3084\u3063\u3066\u3044\u305f\u306e\u304c opts.filter(_ != None).map(_.get) \u3060\u3063\u305f\u3002\u305d\u306e\u5f8c\u3001Scala\u304c\u3060\u3044\u3076\u66f8\u3051\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u9803\u306b for(Some(x) <- opts) yield x \u3084\u3089\u3001 opts.collect{ case Some(x) => x } \u3068\u306a\u308a\u3001\u6700\u7d42\u7684\u306b\u305f\u3069\u308a\u7740\u3044\u305f\u306e\u304c opts.flatten \u3067\u3042\u2026","categories":["Scala"],"height":"190","type":"rich","author_url":"https://blog.hatena.ne.jp/yuimat/","title":"Option\u578b\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089 Some(x) \u306e\u5024 x \u3060\u3051\u3092\u53d6\u308a\u51fa\u3059\u306b\u306f flatten","published":"2016-03-30 09:23:37","version":"1.0","image_url":null,"blog_url":"https://ym.hatenadiary.jp/","url":"https://ym.hatenadiary.jp/entry/2016/03/30/092337","author_name":"yuimat","provider_url":"https://hatena.blog","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fym.hatenadiary.jp%2Fentry%2F2016%2F03%2F30%2F092337\" title=\"Option\u578b\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304b\u3089 Some(x) \u306e\u5024 x \u3060\u3051\u3092\u53d6\u308a\u51fa\u3059\u306b\u306f flatten - Scala\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","width":"100%"}