ComprehensionExpr defines an interface for inspecting a comprehension expression.
| 265 | |
| 266 | // ComprehensionExpr defines an interface for inspecting a comprehension expression. |
| 267 | type ComprehensionExpr interface { |
| 268 | // IterRange returns the iteration range expression. |
| 269 | IterRange() Expr |
| 270 | |
| 271 | // IterVar returns the iteration variable name. |
| 272 | // |
| 273 | // For one-variable comprehensions, the iter var refers to the element value |
| 274 | // when iterating over a list, or the map key when iterating over a map. |
| 275 | // |
| 276 | // For two-variable comprehneions, the iter var refers to the list index or the |
| 277 | // map key. |
| 278 | IterVar() string |
| 279 | |
| 280 | // IterVar2 returns the second iteration variable name. |
| 281 | // |
| 282 | // When the value is non-empty, the comprehension is a two-variable comprehension. |
| 283 | IterVar2() string |
| 284 | |
| 285 | // HasIterVar2 returns true if the second iteration variable is non-empty. |
| 286 | HasIterVar2() bool |
| 287 | |
| 288 | // AccuVar returns the accumulation variable name. |
| 289 | AccuVar() string |
| 290 | |
| 291 | // AccuInit returns the accumulation variable initialization expression. |
| 292 | AccuInit() Expr |
| 293 | |
| 294 | // LoopCondition returns the loop condition expression. |
| 295 | LoopCondition() Expr |
| 296 | |
| 297 | // LoopStep returns the loop step expression. |
| 298 | LoopStep() Expr |
| 299 | |
| 300 | // Result returns the comprehension result expression. |
| 301 | Result() Expr |
| 302 | |
| 303 | // marker interface method |
| 304 | isExpr() |
| 305 | } |
| 306 | |
| 307 | var _ Expr = &expr{} |
| 308 |
no outgoing calls
no test coverage detected