A
ara.t.howard
Another wish list item would be being able to use "a {var_name}"
instead
of "a #{var_name}" I hate that extra pound, as it reminds me of
perl
"a %s" % var_name
a @ http://codeforpeople.com/
Another wish list item would be being able to use "a {var_name}"
instead
of "a #{var_name}" I hate that extra pound, as it reminds me of
perl
I wonder if that fact that regex's always with have two /'s might
help...
probably not - unless you wanted to introduce ';'s to ruby too:
cfp:~ > cat a.rb
x = 1
result =
x / 4 * 2 /
42
p result
I wish... that Range.to_a wouldn't become obselete, as it seems quite useful
in rails!
Assuming you mean Range#to_a (i.e. an instance rather that class
method) I don't think it's becoming obsolete.
And my latest wish
variables that can end in ?
It throws warnings as deprecated, for some reason.
* real keyword arguments in 2.0
Marc said:(By the way, an accessor_read that can query variables with ? on the end
would be nice in std ruby too... I am not complaining at all, ruby is so
flexible, I already use this for my code and i love it, like @file.readable?
that queries a "special" reader accessor... i think it reads nicer than
@file.readable but this is just my opinion)
Do you mean that attr_accessor treats symbols with a question mark
differently by creating a "symbol_without_question=" writer method and a
"symbol_with_question" reader method? For example:
class Foo
attr_acessor :readable? # defines Foo#readable= and Foo#readable?
end
f = Foo.new
f.readable? #=> nil
f.readable = 99
f.readable? #=> 99
This would be very useful, because it would make the following
workaround obsolete:
class Foo
attr_writer :readable # only defines Foo#readable=
def readable?
@readable
end
end
Oh wishing star, here is another wish for you!
Thanks for your consideration.
Todd said:I would think that you would want to maintain the ? behavior across
the board. In other words, it should return TrueClass or FalseClass
objects.
Suraj said:Why? In Ruby, anything that is neither nil nor false is the same as
true... I cannot express how many thousands of times this convention
has simplified my code and eased my life! Furthermore, like method
aliases, this convention falls in line with Ruby's TIMTOWDI philosophy.
So, forcing question-mark methods to return only 'true' and 'false'
feels far too restrictive and seems to follow a
there's-only-one-way-to-do-it philosophy IMHO.
My latest wish, oh wishing star...
(I think something in osx does this)
begin_funcion_name param1 keep_going_function_name param2 end
# so you can have your function calls read really like English
run_if_queue_below 24 every 24 seconds
Suraj Kurapati wrote:
Forcing would be bad, but there is the convention that foo? returns true
vs. false, not something vs. nil.
If a foo? method happens to be returning something other than TrueClass,
and you start depending on that quirk, you run the risk that a later
version of that method returns some other non-nil/non-false object.
Do you mean that attr_accessor treats symbols with a question mark
differently by creating a "symbol_without_question=" writer method and a
"symbol_with_question" reader method? For example:
class Foo
attr_acessor :readable? # defines Foo#readable= and Foo#readable?
end
f = Foo.new
f.readable? #=> nil
f.readable = 99
f.readable? #=> 99
This would be very useful, because it would make the following
workaround obsolete:
class Foo
attr_writer :readable # only defines Foo#readable=
def readable?
@readable
end
end
Oh wishing star, here is another wish for you!
Thanks for your consideration.
There is no such convention in Ruby.
There ARE cases in the ruby language where a x? returns something
other than true or false
defined?(a) # => nil
a = 1
defined?(a) # => "local-variable"
By the way, you really meant true instead of TrueClass right?
The real danger is that you start testing 'truth' with expressions
like x == true or x == false. As long as you don't do that and simply
use the value in conditional expressions like
if x ...
x ? ... : ...
and the like you'll be fine.
You rarely need an actual true/false value in Ruby.
For more on this see
http://www.therailsway.com/2007/8/1/dangers-of-cargo-culting
Clever. I like it.def begin_funcion_name( param1, qualifier1, param2, qualifier1) {
}
run_if_queue_below 24, :every, 24, :seconds
--
Todd said:No convention in Ruby, but in Ruby programmers.
Yes, that's great! No forcing, but just realizing that for your code
to work with others' requires some establishment of convention. Ruby
is a weird and happy monster that way. You can do almost anything
with it, but then when you want to do something with it, you start
setting down ground rules in order to play well with others.
Well, that's kind of just semantics. James may have meant an instance
of TrueClass, but didn't word it that way.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.