<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>letitride</author_name>
  <author_url>https://blog.hatena.ne.jp/letitride/</author_url>
  <blog_title>追憶行</blog_title>
  <blog_url>https://www.letitride.jp/</blog_url>
  <categories>
    <anon>テック</anon>
    <anon>テック-scala</anon>
  </categories>
  <description>絶対忘れるので書いておく。 traitのメソッドのみ使いたい場合、無名クラスにtrait mixinすれば簡単に利用できる。 このように対象のtraitがあった場合、 trait Job { def p(str:String) = {println(str); str} } ダメなケース。 new Job() traitそのものはインスタンス化できないので、当然だめ。 無名クラスインスタンスとして利用する 考え方としては、traitをmixinした無名クラスのインスタンスを作成する。という方法。といっても特別なことは何もない。 無名クラスの作成は new { val name = &quot;strin…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.letitride.jp%2Fentry%2F2020%2F05%2F12%2F165514&quot; title=&quot;Scala traitの無名クラスmixin - 追憶行&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-05-12 16:55:14</published>
  <title>Scala traitの無名クラスmixin</title>
  <type>rich</type>
  <url>https://www.letitride.jp/entry/2020/05/12/165514</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
