What is the Scala type-programming analogy for the `this` keyword? -


I'm trying to work in my own way to understand type-programming in Scala, and I've found that Most of us need to know about typing programming. There is an equivalent equivalent in price programming as reflected in it, however, I do not have to get it according to the this key word or self-type. It is expected of such things Rsha does not mean to, but I thought I'd ask.

For example, I can write the following to represent Boolean as values ​​in the run time:

  Sealed attribute BoolVal {def not: BoolVal def or (Key: BoolVal): BoolVal def and (Key: BoolVal) = (this.not or that.not) def Imp .not (that: BoolVal) = this.not Or that} case object TrueVal extends BoolVal {do not dominate domes = FalseVal def override or (Key: BoolVal) = TrueVal} case object FalseVal extends BoolVal {Val = No TrueVal override def or o Ride (Key: BoolVal) that =}   

Here my and and imp are able to take advantage of the fact that this is someone It does not matter if I have the right thing to define the wrong thing or the right object, my code can get the same code as TrueVal and FalseVal objects.

I can create similar type-level programming, but I do not understand how and and IM are my base attributes To define in "seal" feature is not a type of type type: type type: BoolType] = True Type} Seal Attribute FalseType Extends BoolType {Not Dominate Type = TrueType Override Type or [that is & lt; : BoolType] = that}

I can see that it does not come from the type of my type, and and Is there a way to define> my BoolType in Implements , or should I Each is to define and wrong type Symptoms?

You can always define an abstract type of your Boolean base type as follows:

  attribute MyBool extends BoolType {Type is   

It should be good to go along, after which you can use the rules of Demorgon to do the following tasks

 ! (X & Y) == (! X ||! Y)   

Then you can run the and status by a double negative:

 ! (! X ||! Y) == !! (X & amp; y) == (X & amp; nbsp;)    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -