如何调用 Perl 标量上的方法?
我看到一些在标量(数字)上调用方法的代码,例如:
print 42->is_odd
您必须重载什么才能在代码中实现这种“功能”?
I saw some code that called methods on scalars (numbers), something like:
print 42->is_odd
What do you have to overload so that you can achieve this sort of "functionality" in your code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是使用自动装箱功能的示例。
This is an example using the autobox feature.
您指的是 autobox 吗?另请参阅我应该在 Perl 中使用 autobox 吗?。
Are you referring to autobox? See also Should I use autobox in Perl?.