我最近在阅读"Groovy in Action".在第7章中,它介绍了*.运营商.当我运行有关此运算符的代码时,我会遇到一些错误.
class Invoice {
List items
Date date
}
class LineItem {
Product product
int count
int total() {
return product.dollar * count
}
}
class Product {
String name
def dollar
}
def ulcDate = new Date(107,0,1)
def ulc = new Product(dollar:1499, name:'ULC')
def ve = new Product(dollar:499, name:'Visual Editor')
def invoices = [
new Invoice(date:ulcDate, items: [
new LineItem(count:5, product:ulc),
new LineItem(count:1, product:ve)
]),
new Invoice(date:[107,1,2], items: [
new LineItem(count:4, product:ve)
])
]
//error
assert [5*1499, …Run Code Online (Sandbox Code Playgroud) groovy ×1