是否有 textmate 或 sublime text 2 的捆绑包可以向我显示 ruby 方法返回的值?
是否有 textmate 或 sublime text 2 的捆绑包可以告诉我 ruby 方法返回什么值?
我正在寻找带有工具提示的内容,我可以将其悬停在语句上并让它告诉我该方法返回什么。
Is there bundle for textmate or sublime text 2 that will show me what value a ruby method returns?.
I'm looking for something with a tooltip that I can hover over a statement and have it tell me what the method returns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,没有。对于返回值的方法,您需要执行该方法,传入任何适当的参数并对对象实例的当前状态进行操作。此外,方法的值可能会根据对象状态和参数而改变。文本编辑器怎么知道这些是什么?
“方法的返回值”唯一有意义的时候是在调试期间,当您停止执行并正在评估特定的方法调用时。 TextMate 和 Sublime Text 都不是 IDE,因此不提供基于行的调试。
No, there is not. For a method to return a value, you need to execute that method, passing in any appropriate parameters and operating on the current state of the object instance. Further, the value of a method may change depending on object state and parameters. How would the text editor have any idea what these would be?
The only time that "return value for a method" makes sense is during debugging, when you have stopped execution and are evaluating a particular method invocation. Neither TextMate nor Sublime Text are IDEs, and thus do not provide line-based debugging.
这可能会满足您的需求: sublime-text-2-ruby-markers
安装:
从 Sublime Text 2:
工具>命令面板
查找并安装“Ruby Markers”
现在,当您键入一行代码时,请在该行后面附加“# =>”并按 Shift+Alt+U 查看该行的返回值。您还可以只添加“#”,后跟制表符以节省一些击键(至少在 Mac 上)。
默认情况下,程序的任何输出也会作为注释打印到文件底部,因此要禁用它:
菜单>首选项>套餐设置>红宝石标记>设置-用户
并粘贴此:
<代码>
{
“strip_stdout”:正确,
“xmpfilter_quiet”:真
}
哇,
这是一个老问题了:)
This might do what you're looking for: sublime-text-2-ruby-markers
To install:
From Sublime Text 2:
Tools > Command Palette
Find and Install "Ruby Markers"
Now when you type a line of code, append the line with " # =>" and hit Shift+Alt+U to see the return value of that line. You can also just add " #" followed by tab to save a few keystrokes (on a mac at least)
By default, any output from your program will also print as a comment to the bottom of your file, so to disable that:
Menu > Preferences > Package Settings > Ruby Markers > Settings - User
And paste this:
{
"strip_stdout": true,
"xmpfilter_quiet": true
}
Wow this is an old question :)