電子書籍の厳選無料作品が豊富!

java.io.Fileクラスをscala.jisaku.DFクラスに継承させたいので、次のようなコーディングをしました.
[Samp.scala]
import java.io._
class DF(path:String) extends java.io.File{
File(path)
}

上のSamp.scalaをコンパイルすると下の様なエラーが出ました.
error: overloaded method constructor File with alternatives:
(x$1: java.net.URI)java.io.File <and>
(x$1: java.io.File,x$2: String)java.io.File <and>
(x$1: String,x$2: String)java.io.File <and>
(x$1: String)java.io.File
cannot be applied to ()
class DF(path:String) extends java.io.File
error: not found: value path
class box extends DF(path:String)
^
two errors found

まず、コードの
File(path)
は、メソッドでなくコンストラクタを実行したときの処理として扱いたいのですが上ではだめなのでしょうか?
どのようにしたら良いでしょうか?

A 回答 (1件)

http://www.ne.jp/asahi/hishidama/home/tech/scala …
によれば, extends のところでコンストラクタを呼べばいいってさ.
    • good
    • 0
この回答へのお礼

ありがとうございます.

お礼日時:2016/06/22 19:37

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!