在Eclipse中创建Scala脚本文件 [英] create a Scala script file in Eclipse

查看:132
本文介绍了在Eclipse中创建Scala脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和Scala一起玩。我需要的只是函数定义的早午餐,但是在Eclipse中,我只能创建 def .scala 文件。 c>必须在对象或类内。

I am playing with Scala. What I need is just a brunch of function definitions, but in Eclipse I can only create .scala files for which a function def must be inside an object or class.

但是我在网上看到一个Scala脚本,此处,它不使用对象来包装所有功能。

But I see a Scala script online, here, which does not use an object to wrap all the functions.

使用对象包装我的所有函数当然是可以的,但是我只是想知道是否需要它。谢谢!

It is of course ok for me to use an object to wrap all my functions, but I am just wondering whether it is required. Thanks!

推荐答案


但是我在这里看到了一个Scala脚本,它没有使用对象包装所有功能。

But I see a Scala script online, here, which does not use an object to wrap all the functions.

请注意,在这种情况下,不能从其他文件调用函数(它们包装在对象,并在运行时提供编译器生成的名称)。如果只需要函数定义的早午餐,则可能不是您想要的:) AFAIK,Scala IDE目前不支持脚本文件,但是您可以记录功能请求此处

Note that in this case, the functions can't be called from other files (they are wrapped in an object with compiler-generated name when run). If you "need just a brunch of function definitions", this is likely not what you want :) AFAIK, Scala IDE doesn't support script files at the moment, but you could log a feature request here.

这篇关于在Eclipse中创建Scala脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆