# Rake task with arguments

**URL:** <https://www.ruby-forum.com/t/rake-task-with-arguments/130154>\
**Category:** Ruby\
**Created:** [February 25, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/rake-task-with-arguments/130154 "2008-02-25T21:42:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![reacher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/0ea827/32.png) [@reacher](https://www.ruby-forum.com/u/reacher)\
**Post date:** [February 25, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/rake-task-with-arguments/130154/1 "2008-02-25T21:42:41Z")

</div>

I found an example ([http://www.betweentherails.com/rake/](http://www.betweentherails.com/rake/)) of passing  
arguments to a rake task in the new (0.8.n) version of rake. From this  
example, I created the following test:

namespace :foo do  
desc ‘lol’  
task :bar, :num do |t, args|  
puts “num = #{args.num}”  
end  
end

I took a look at the task list:

$ rake --tasks  
(in /path/to/my/dir)  
rake foo:bar[num] # lol

All looks well … until I try to run it:

$ rake foo:bar[123]  
rake: No match

Hmm … let’s try without the argument:

$ rake foo:bar  
(in /path/to/my/dir)  
num =

o.O
