成员变量/方法/getter 和 setter 是否可以封装在一个通用的访问修饰符中?
有没有一种方法可以使用一个公共访问修饰符来声明一堆成员?我确实相信这可以用 C++ 和其他一些语言来完成,但好奇它是否存在于 AS3 中。
而不是:
class FooBar {
public var theDog:String = "Bark!";
public var theCat:String = "Miao!";
private var myBird:String = "Chirp!";
private var myPig:String = "Oink!";
}
可以写成:
class FooBar {
public {
var theDog:String = "Bark!";
var theCat:String = "Miao!";
}
private {
var myBird:String = "Chirp!";
var myPig:String = "Oink!";
}
}
Is there a way to declare a bunch of members with one common access modifier? I do believe this can be done in C++ and some other languages, curious if it exists in AS3 though.
Instead of:
class FooBar {
public var theDog:String = "Bark!";
public var theCat:String = "Miao!";
private var myBird:String = "Chirp!";
private var myPig:String = "Oink!";
}
It could be written as:
class FooBar {
public {
var theDog:String = "Bark!";
var theCat:String = "Miao!";
}
private {
var myBird:String = "Chirp!";
var myPig:String = "Oink!";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你可以写:
I think you can write:
我希望,但遗憾的是,Flash/Flex 编译器没有这样的快捷方式(在定义一大块静态成员时我真的很怀念)。
I wish, but sadly, the Flash/Flex compiler has no such shortcut (which I really miss when defining a chunk of static members).