はあなたのコード の内容を使用してファイルCharge.scala
を作成し、scalac -print Charge.scala
を使用してコードをコンパイルし、あなたが取得します:
[syntax trees at end of cleanup]] // Test.scala
package <empty> {
case class Charge extends Object with Product with Serializable {
<caseaccessor> <paramaccessor> private[this] val cc: Int = _;
<stable> <caseaccessor> <accessor> <paramaccessor> def cc(): Int = Charge.this.cc;
<caseaccessor> <paramaccessor> private[this] val amount: Double = _;
<stable> <caseaccessor> <accessor> <paramaccessor> def amount(): Double = Charge.this.amount;
<synthetic> def copy(cc: Int, amount: Double): Charge = new Charge(cc, amount);
<synthetic> def copy$default$1(): Int = Charge.this.cc();
<synthetic> def copy$default$2(): Double = Charge.this.amount();
override <synthetic> def productPrefix(): String = "Charge";
<synthetic> def productArity(): Int = 2;
<synthetic> def productElement(x$1: Int): Object = {
case <synthetic> val x1: Int = x$1;
(x1: Int) match {
case 0 => scala.Int.box(Charge.this.cc())
case 1 => scala.Double.box(Charge.this.amount())
case _ => throw new IndexOutOfBoundsException(scala.Int.box(x$1).toString())
}
};
override <synthetic> def productIterator(): Iterator = runtime.this.ScalaRunTime.typedProductIterator(Charge.this);
<synthetic> def canEqual(x$1: Object): Boolean = x$1.$isInstanceOf[Charge]();
override <synthetic> def hashCode(): Int = {
<synthetic> var acc: Int = -889275714;
acc = Statics.this.mix(acc, Charge.this.cc());
acc = Statics.this.mix(acc, Statics.this.doubleHash(Charge.this.amount()));
Statics.this.finalizeHash(acc, 2)
};
override <synthetic> def toString(): String = ScalaRunTime.this._toString(Charge.this);
override <synthetic> def equals(x$1: Object): Boolean = Charge.this.eq(x$1).||({
case <synthetic> val x1: Object = x$1;
case5(){
if (x1.$isInstanceOf[Charge]())
matchEnd4(true)
else
case6()
};
case6(){
matchEnd4(false)
};
matchEnd4(x: Boolean){
x
}
}.&&({
<synthetic> val Charge$1: Charge = x$1.$asInstanceOf[Charge]();
Charge.this.cc().==(Charge$1.cc()).&&(Charge.this.amount().==(Charge$1.amount())).&&(Charge$1.canEqual(Charge.this))
}));
def <init>(cc: Int, amount: Double): Charge = {
Charge.this.cc = cc;
Charge.this.amount = amount;
Charge.super.<init>();
scala.Product$class./*Product$class*/$init$(Charge.this);
()
}
};
<synthetic> object Charge extends scala.runtime.AbstractFunction2 with Serializable {
final override <synthetic> def toString(): String = "Charge";
case <synthetic> def apply(cc: Int, amount: Double): Charge = new Charge(cc, amount);
case <synthetic> def unapply(x$0: Charge): Option = if (x$0.==(null))
scala.this.None
else
new Some(new Tuple2$mcID$sp(x$0.cc(), x$0.amount()));
<synthetic> private def readResolve(): Object = Charge;
case <synthetic> <bridge> <artifact> def apply(v1: Object, v2: Object): Object = Charge.this.apply(scala.Int.unbox(v1), scala.Double.unbox(v2));
def <init>(): Charge.type = {
Charge.super.<init>();
()
}
}
}
伝えていますcc()
という方法でオブジェクトの実際のプロパティからthis.cc
が提供されています。
大文字小文字クラスについては、さまざまな種類のオンラインドキュメントがあります。[公式のもの](http://docs.scala-lang.org/tutorials/tour/case-classes.html)は、 – cchantep
@cchantep私はすでにそれを読んでいて、私の質問に対する答えを得ることができませんでした。 –