Родитель/Ребенок Groovy Частная Странность Доступа к полю С Закрытием

Для комфортной работы вы можете установить в среде разработчика cookie_lifetime to 0, это означает, что срок действия файла cookie истекает при закрытии браузера.

Файл: config_dev.php

  framework:
        session:
            cookie_lifetime: 0
5
задан awyatt 4 June 2009 в 15:25
поделиться

1 ответ

This is a known bug in the current version of groovy and is targeted for being fixed in groovy 2.0. See GROOVY-3073.

It's happening because of a scoping bug in the metaclass where the closure in the first example can't see the private class level variable.

One potential fix that gets around the issue for this situation is to declare a local alias variable in the superclass, this gets around the scoping issue in the closure. Change the constructor to this:

  ParentClass(columnCount) {
     def valueAlias = values
     columnCount.times { valueAlias.add('') }
  }
5
ответ дан 14 December 2019 в 19:23
поделиться
Другие вопросы по тегам:

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