gpt4 book ai didi

ceylon - 如何在 Ceylon 中获取命令行参数?

转载 作者:行者123 更新时间:2023-12-01 08:54:59 24 4
gpt4 key购买 nike

在命令行 Java 应用程序中,您可以通过 args 参数获取参数:

public static void main(String[] args) {

如何在 ceylon 做类似的事情?我尝试复制 Java 样式:

shared void run(String[] args) {

但由于不允许这样做而出现错误:

ceylon run: Cannot run toplevel method 'test.project.run': 
it should have no parameters or they should all have default values.

我一直在阅读 ceylon-lang.org 导览,但没有找到答案。

最佳答案

使用顶级 process语言模块中的对象。

String[] arguments = process.arguments;
String? argument = process.namedArgumentValue("name");
if (process.namedArgumentPresent("name")) {
// ...
}

关于ceylon - 如何在 Ceylon 中获取命令行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28788525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com