小编Wil*_*bin的帖子

Dart 中输出或引用参数的等效代码

在 Dart 中,我如何最好地编写等效于(不可变/值/非对象)输出或引用参数的代码

例如在 C#-ish 中,我可能会编码:

function void example()
{
  int result = 0;
  if (tryFindResult(anObject, ref result))
    processResult(result);
  else
    processForNoResult();
}

function bool tryFindResult(Object obj, ref int result)
{
  if (obj.Contains("what I'm looking for"))
  {
    result = aValue;
    return true;
  }
  return false;  
}
Run Code Online (Sandbox Code Playgroud)

dart

7
推荐指数
1
解决办法
2527
查看次数

标签 统计

dart ×1