아파치 쓰리프트(apache thrift)의 bool 타입은 true와 false만 사용할 수 있다.


https://thrift.apache.org/docs/types


  • bool: A boolean value (true or false)

만약 null이면 false로 이해한다.




만약 true, false, not_set의 의미로 3개의 상태 값을 갖게 하려면 byte(i32 등등) 또는 enum을 사용하는 것이 좋다.






Posted by '김용환'
,

스칼라에서는 underscore를 많은 용도로 사용할 수 있다.


그 중 변수를 기본값으로 초기화를 하라라는 의미이다. 


scala>  var a: String = _

a: String = null



var에 underscore를 사용할 수 있지만, val에 사용하면 에러를 리턴한다. 



scala>  val a: String = _

<console>:11: error: unbound placeholder parameter

        val a: String = _

                        ^


함수도 초기화할 수 있다.


private var myExpr: () => Int = _






scala 언어 스펙에 따르면.. 다음과 같이 정의하고 있다.

http://www.scala-lang.org/files/archive/spec/2.11/06-basic-declarations-and-definitions.html




A variable definition var $x$: $T$ = _ can appear only as a member of a template. It introduces a mutable field with type $T$ and a default initial value. The default value depends on the type $T$ as follows:

defaulttype $T$
0Int or one of its subrange types
0LLong
0.0fFloat
0.0dDouble
falseBoolean
()Unit
nullall other types



Posted by '김용환'
,