com.thoughtworks.dsl.keywords
杨博 (Yang Bo)
Yield keywords can be used together with other keywords.
def gccFlagBuilder(sourceFile: String, includes: String*): Stream[String] = { !Yield("gcc") !Yield("-c") !Yield(sourceFile) val include = !Each(includes) !Yield("-I") !Yield(include) !Continue } gccFlagBuilder("main.c", "lib1/include", "lib2/include") should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
This Yield keyword must be put inside a function that returns Seq[Element] or Seq[Element] !! ..., or it will not compile.
Yield
Seq[Element]
Seq[Element] !! ...
"def f(): Int = !Yield(1)" shouldNot compile
comprehension if you want to use traditional for comprehension instead of !-notation.
for
An alias to cpsApply.
(yield: Yield[Yield[Element]]).apply(handler)(dsl)
(yield: Yield[Yield[Element]]).cpsApply(handler)(dsl)
(yield: Yield[Yield[Element]]).element
(yield: Yield[Yield[Element]]).unary_!
Author:
杨博 (Yang Bo)
Yield keywords can be used together with other keywords.
This
Yield
keyword must be put inside a function that returnsSeq[Element]
orSeq[Element] !! ...
, or it will not compile."def f(): Int = !Yield(1)" shouldNot compile
comprehension if you want to use traditional
for
comprehension instead of !-notation.