I'm in the process of absorbing information about Ruby and Puppet, both of which I have no real experience with (although I've been writing code in other languages for many years).
I cloned the repo of an existing Puppet project, which I believe is working fine for the people who are using it.
I imported the project into Eclipse, and I noticed error markers in a couple blocks of code. Here's one of them:
It was complaining about the trailing comma in the argument list.
Again, it seems unlikely to me that the people using this project are getting this error. Is there some sort of version difference between the Ruby my Eclipse is using and the Ruby that is likely used with Puppet?
I assume it is an error in syntax highlighting of the editor you use -
not in Ruby.
$ ruby -ce 'f(1,2,)'
Syntax OK
$ ruby -ce 'f(1=>2,3=>4,)'
Syntax OK
$ ruby -v
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
Cheers
robert
···
On Fri, Apr 22, 2016 at 11:22 PM, David M. Karr <davidmichaelkarr@gmail.com> wrote:
I'm in the process of absorbing information about Ruby and Puppet, both of
which I have no real experience with (although I've been writing code in
other languages for many years).
I cloned the repo of an existing Puppet project, which I believe is working
fine for the people who are using it.
I imported the project into Eclipse, and I noticed error markers in a couple
blocks of code. Here's one of them:
----------------
it { is_expected.to contain_keystone_user('congress').with(
:ensure => 'present',
:password => 'congress_password',
) }
-------------
It was complaining about the trailing comma in the argument list.
Again, it seems unlikely to me that the people using this project are
getting this error. Is there some sort of version difference between the
Ruby my Eclipse is using and the Ruby that is likely used with Puppet?
It seems to have been valid syntax since at least 1.9.3,
i.e. for many years:
Thank you for explicitly pointing that out! The syntax is so familiar
that I did not even bothered to mention it's been around for ages. But
I can see how not everybody joining is aware of that.
Robert, thanks for pointing out the `-c' option!
You're welcome!
Kind regards
robert
···
On Sat, Apr 23, 2016 at 1:20 PM, <sto.mar@web.de> wrote:
Thank you for explicitly pointing that out! The syntax is so familiar
that I did not even bothered to mention it's been around for ages.
actually I learned about it just now
(and it does look strange to me...)
Regards,
Marcus
I like trailing commas because they let lists (including argument lists ) not have special first or last elements in a source file, which let me easily textually manipulate the list (e.g. sort it). I much prefer source laid out like this:
list = [
'foo',
'bar',
'baz',
]
so I could easily sort or remove or add an element without a special case (e.g. the "ugly-to-me"
list = [ 'foo'
, 'bar'
, 'baz'
]
or
list = [ 'foo',
'bar',
'baz' ]
where one or more lines have a different format.)
These days I let community / workplace style override my preferences, but I’m grateful that Ruby allows me to do it the way I like in the right contexts
Mike
···
On Apr 23, 2016, at 7:39 AM, sto.mar@web.de wrote:
Am 23.04.2016 um 13:29 schrieb Robert Klemme:
I prefer to avoid commas and quoting entirely by using %w:
list = %w(
foo
bar
baz
)
Or %W, which allows variable expansion:
var = 'word with spaces'
list = %W(
#{var}
bar
baz
)
···
Mike Stok <mike@stok.ca> wrote:
I like trailing commas because they let lists (including
argument lists ) not have special first or last elements in a
source file, which let me easily textually manipulate the list
(e.g. sort it). I much prefer source laid out like this:
I never use a trailing comma for function args, though. I guess I'm more
deliberate with those, and they don't get cut-and-pasted line by line so
much.
···
On 24/04/2016 11:14 AM, "Eric Wong" <normalperson@yhbt.net> wrote:
I prefer to avoid commas and quoting entirely by using %w:
list = %w(
foo
bar
baz
)
Or %W, which allows variable expansion:
var = 'word with spaces'
list = %W(
#{var}
bar
baz
)
Agreed. My liking of it in other “list-y” contexts meant that its *availability* in an argument list it didn’t surprise me.
···
On Apr 23, 2016, at 10:24 PM, Matthew Kerwin <matthew@kerwin.net.au> wrote:
I never use a trailing comma for function args, though. I guess I'm more deliberate with those, and they don't get cut-and-pasted line by line so much.