Вопрос по – Какие символы я могу опустить в Scala?

23

Error: User Rate Limit ExceededT m 0Error: User Rate Limit ExceededT.m(0)Error: User Rate Limit Exceeded

scala> object T { def m(i:Int) = 0 == i }
defined module T

scala> T m 0
res19: Boolean = true

Error: User Rate Limit Exceededn(0)Error: User Rate Limit Exceeded

scala> def n(i:Int) = 0 == i
n: (Int)Boolean

scala> n 0
<console>:1: error: ';' expected but integer literal found.
       n 0
         ^

Ваш Ответ

2   ответа
3

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
37

class MyByte(val n : Int) {
  require(n >= 0 && n <= 255)
  def unary_! = new MyByte(n ^ 0xff)
  def +(m : MyByte) = new MyByte(n + m.n)
  def bits = (math.log(n) / math.log(2) + 1).toInt
  override def toString = "0" * (8 - bits) + n.toBinaryString
}

scala> val a = new MyByte(5)
a: MyByte = 00000101

scala> val b = new MyByte(10)
b: MyByte = 00001010

scala> ! a  // Prefix/Unary
res58: MyByte = 11111010

scala> a + b  // Infix
res59: MyByte = 00001111

scala> b bits  // Postfix
res60: Int = 4

Error: User Rate Limit Exceeded:Error: User Rate Limit ExceededfixityError: User Rate Limit Exceededright associativeError: User Rate Limit Exceededleft associativeError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы