【问题标题】:How to list down all methods with livescript?如何使用 livescript 列出所有方法?
【发布时间】:2014-04-04 17:06:34
【问题描述】:

在python中有目录(模块):

In [6]: dir(datetime) Out[6]: ['MAXYEAR', 'MINYEAR', '__doc__', '__file__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo']

Elixir 你可以输入模块名称然后按 Tab 键,然后它会列出一个方法所具有的所有功能。

iex(1)> String. Chars at/2 capitalize/1
codepoints/1 contains?/2 downcase/1
duplicate/2 ends_with?/2 first/1
from_char_list!/1 from_char_list/1 graphemes/1
last/1 length/1 ljust/2
ljust/3 lstrip/1 lstrip/2
match?/2 next_codepoint/1 next_grapheme/1

在 ruby​​ 中你有 methods

[2] pry(main)> File.methods => [:directory?, :exist?, :exists?, :readable?, :readable_real?, :world_readable?, :writable?, :writable_real?, :world_writable?, :executable?, :executable_real?, :file?, :zero?, :size?, ...]

livescript 中是否有等价物?

【问题讨论】:

  • 查看我的扩展答案。

标签: livescript


【解决方案1】:

也许使用来自prelude.ls - keys - http://preludels.com/#keys 的函数

编辑:

使用-d 标志自动将prelude.ls 导入repl。

$ lsc -d
LiveScript 1.2.0 - use 'lsc --help' for more information
ls> keys require 'assert'
[ 'AssertionError',
  'fail',
  'ok',
  'equal',
  'notEqual',
  'deepEqual',
  'notDeepEqual',
  'strictEqual',
  'notStrictEqual',
  'throws',
  'doesNotThrow',
  'ifError' ]

【讨论】:

  • 谢谢,这是一个很好的方法。我发现我也可以为默认加载的模块按 tab 键,或者为 livescript 按下“builtins”来告诉我它们的所有模块。
猜你喜欢
  • 1970-01-01
  • 2013-01-01
  • 2016-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多