我想添加--group-directories-first到ls命令。如果~/.config/fish/config.fish我可以定义这样的别名:
alias ls "ls --group-directories-first"
Run Code Online (Sandbox Code Playgroud)
但它会覆盖鱼壳的ls函数定义:
function ls --description 'List contents of directory'
set -l param --color=auto
if isatty 1
set param $param --indicator-style=classify
end
command ls $param $argv
end
Run Code Online (Sandbox Code Playgroud)
我可以重新定义ls函数以添加所需的参数:
function ls --description 'List contents of directory'
set -l param --color=auto --group-directories-first
if isatty 1
set param $param --indicator-style=classify
end
command ls $param $argv
end
Run Code Online (Sandbox Code Playgroud)
但是我不喜欢这种解决方案:我想要的是重新定义ls以便ls使用参数调用前一个函数。有办法做到吗?
Ruby语法参考说明了case语句:
比较由运营商完成
===
事实上,例如:
ruby -e 'puts (1..3) === 2'
Run Code Online (Sandbox Code Playgroud)
打印true,但是:
ruby -e 'puts "foo" === /foo/'
Run Code Online (Sandbox Code Playgroud)
打印false,还:
ruby -e 'puts :foo === /foo/'
Run Code Online (Sandbox Code Playgroud)
打印false,但所有这些示例都是case语句的成功条件.它是如何工作的?
出于学习目的,我创建了一个博客,现在我想在其创建30天后自动销毁该帖子。我该怎么做?
这是我的帖子控制器
def index
@posts = Post.all
end
def create
@post = current_user.posts.new(post_params)
@post.save
redirect_to posts_path
end
def destroy
@post.destroy
redirect_to posts_path
end
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的ubuntu 14.04上使用rbenv安装ruby 2.1.1.我使用了以下命令.
curl -fsSL https://gist.github.com/mislav/a18b9d7f0dc5b9efc162.txt | rbenv install --patch 2.1.1
Run Code Online (Sandbox Code Playgroud)
但几分钟后它停止响应,我得到如下输出.
Downloading ruby-2.1.1.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/e57fdbb8ed56e70c43f39c79da1654b2
Installing ruby-2.1.1...
patching file ext/readline/readline.c
patching file ext/readline/extconf.rb
patching file ext/readline/extconf.rb
Run Code Online (Sandbox Code Playgroud)
之后,它停止响应,会出现什么问题?