Simon --

Being unsure of which part is confusing you, here's a brief run-down:

If you place a statement between backticks (the little guys above the
left tab on your keyboard) it will execute a command from the terminal
and return the output. Try `ls` under OSX and `dir` under Windows. You
can use `open` (osx) and `start` (win) to open a file with the default
application for the file type.

In a double quoted string, you can put an object between #{} to
dynamically build the string.
For example --
a = ['Claire', 'Jennifer', 'Margaret']
a.each {|x| puts "Hello, #{x}"}

Very neat, and you can use it in all sorts of useful things.

On 8/16/07, Logan Capaldo <logancapaldo / gmail.com> wrote:
> On 8/16/07, Simon Schuster <significants / gmail.com> wrote:
> > whoa, can you explain a little what's going on here? I tried it and
> > changed it around in irb but I can't really figure out what's going
> > on.
> >
>
> #{} just happens to work more places than string literals:
>
> If it helps clear it up, /#{needle}/ is roughly equivalent to
>
> Regexp.new("#{needle}") which is sort of a silly use of interpolation,
> so let's write it as:
> Regexp.new(needle)
>
> So yeah, the string "bar" was used to construct the regexp /bar/.
>
> > >
> > > For added fun, try string interpolation inside regular expressions!
> > >
> > > haystack = "foobarbaz"
> > > needle = "bar"
> > >
> > > haystack =~ /#{needle}/
> > > => 3
> > >
> > > yeah :D
> > >
> > >
> >
> >
>
>