本文介绍了飞镖和下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定在Dart中实现功能性underscore.js库。



我在'underscore.dart'中编写了函数,并显示了以下示例函数:

 库下划线; 

List _filter(ff,List s)=>返回s..retainWhere(ff);

List _dropWhile(ff,List s)=> s.skipWhile(ff).toList();

在我的主Dart程序中,然后添加了导入语句

  import'underscore.dart'; 

但是,我在未使用的导入这一行遇到了持续的错误,因此没有函数被识别。



进一步的测试表明,引起问题的是函数名上的下划线。



有什么想法吗?

解决方案

下划线表示该函数是图书馆私人的。也就是说,您不能在其他库中使用它。参见。


I decided to implement the functional underscore.js library in Dart.

I wrote the functions in 'underscore.dart' with some example functions shown below:

library underscore;

List _filter (ff, List s) => return s..retainWhere(ff);

List _dropWhile(ff,List s) => s.skipWhile(ff).toList();

In my main Dart program, I then added the import statement

import 'underscore.dart';

However, I got the persistent error on that line of 'Unused Import', and so none of the functions were recognised.

It did work, though, when I redefined 'underscore.dart' as 'part of mainProg' and made 'mainProg' a library in its own right.

Further testing shows that it is the underscores on the function names that is causing the problem.

Any ideas?

解决方案

A prepending underscore means that the function is library private. That is, you can't use it in an other library. See Libraries and Visibility.

这篇关于飞镖和下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:18