start_with? Does someone need a grammar lesson?

7

7stud --

String#start_with?-------------------------------

str.start_with?([prefix]+) => true or false

From Ruby 1.9.1
------------------------------------------------
Returns true if _str_ starts with the prefix given.


Whoever wrote the docs doesn't:

Returns true if _str_ **starts with** the prefix given. I find it so
jarring to read:

if mystring.start_with?("bad grammar")

I'm hesitant to use start_with?() in my code. It makes me look
uneducated. :(
 
P

Peter Booth

[Note: parts of this message were removed to make it a legal post.]




You can fix the English grammar in a number of ways. For example:

define a function does

does mystring.start_with?("bad grammar")

or, even worse, rename your variable

if my_characters.start_with?("good grammar") # i'm choosing
grammatical correctness by breaking the semantics

Remember, "A foolish consistency is the hobgoblin of little minds,
adored by little statesmen and philosophers and divines."

English grammar is sufficiently arbitrary, and fluid, to be a poor
indicator of programming language quality.

Peter
 
7

7stud --

7stud said:
I'm hesitant to use start_with?() in my code. It makes me look
uneducated. :(

Hmm...I guess start_with?'s name is consistent with the naming
"convention" used by some other ruby methods, such as respond_to.
 
R

Rick DeNatale

Hmm...I guess start_with?'s =A0name is consistent with the naming
"convention" used by some other ruby methods, such as respond_to.

Yep, I too found it a bit jarring when I first started using Ruby,
but it has become one of those things you just accept, just like
accepting that if you're speaking French must adjectives come after
nouns.


--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
R

Roger Pack

I'm hesitant to use start_with?() in my code. =A0It makes me look
uneducated. :(

I'd be quite happy if someone came up with a gem that aliased
"correct" english method names to the existing :)
-r
 
R

Robert Dober

Yep, =A0I too found it a bit jarring when I first started using Ruby,
but it has become one of those things you just accept, just like
accepting that if you're speaking French must adjectives come after
nouns.

I bet you prefer that I call you "vieux ami" instead of "ami vieux" though!

But your observation is correct and can be extended to most latin languages=
 
D

Dominik Honnef

if mystring.start_with?("bad grammar")

I'm hesitant to use start_with?() in my code. It makes me look
uneducated. :(

mystring.start_with? (or include? or respond_to? and so on) are best
liked when read and understood as a question:

do you [mystring] start with "bad grammar"?
 
J

Joel VanderWerf

Dominik said:
if mystring.start_with?("bad grammar")

I'm hesitant to use start_with?() in my code. It makes me look
uneducated. :(

mystring.start_with? (or include? or respond_to? and so on) are best
liked when read and understood as a question:

do you [mystring] start with "bad grammar"?

Or

does mystring start with "bad grammar"?

maybe we should lobby to replace "if" with "does" :p
 
R

Rick DeNatale

2009/8/17 Robert Dober said:
I bet you prefer that I call you "vieux ami" instead of "ami vieux" thoug= h!

Well, I committed a typo, that I realized right away, but was too
lazy? to correct.

I meant to say that in French most adjectives come after nouns.

In English the sentence, "Must adjectives come after nouns." is
ungrammatical unless the period is changed to a question mark.



--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
R

Robert Dober

Well, I committed a typo, that I realized right away, but was too
lazy? to correct.

I meant to say that in French most adjectives come after nouns.

In English the sentence, "Must adjectives come after nouns." is
ungrammatical unless the period is changed to a question mark.

Now I am confused. But no, they do not need to stand after nouns,
often short ones stand in front.
E.g.
C'est une belle femme.
vs.
C'est une femme sympathique.
(same for Italian)
And in the example I gave the semantic changes.
Vieux ami --> Good old friend
Ami vieux --> Aged friend
(same for Italian, no wonder the French learn it so quickly)

But in general they do stand behind nouns. Are there not some examples
of adjectives after the noun in English too, poetry?

Cheers
Robert



--=20
module Kernel
alias_method :=CE=BB, :lambda
end
 
T

Todd Benson

if mystring.start_with?("bad grammar")

I'm hesitant to use start_with?() in my code. It makes me look
uneducated. :(

mystring.start_with? (or include? or respond_to? and so on) are best
liked when read and understood as a question:

do you [mystring] start with "bad grammar"?

Nah, it's a common artifact of moving east asian grammar to western.
Besides that, you shouldn't try to reinvent by changing the wheel.
People obviously think that proper would be "a single object" "starts
with". But if you think of that simple object for what it is, a bunch
of bytes, than the discrepancy goes away. It's plural vs. singular.
Don't really care.

Todd
 
T

Todd Benson

Nah, it's a common artifact of moving east asian grammar to western.
Besides that, you shouldn't try to reinvent by changing the wheel.
People obviously think that proper would be "a single object" "starts
with". But if you think of that simple object for what it is, a bunch
of bytes, than the discrepancy goes away. It's plural vs. singular.
Don't really care.

I didn't give an example. My bad...

things_that_are_important_to_me starts with "start"

Todd
 
D

Dominik Honnef

Todd Benson said:
I didn't give an example. My bad...

things_that_are_important_to_me starts with "start"

Todd

I honestly rather like to explain this "artifact" by the fact what it
is. A message sent to a receiver. You ask a receiver about its state,
not the world around it. So "do you" actually makes more sense than
asian/western grammar as an explanation, imho.
 
T

Todd Benson

I honestly rather like to explain this "artifact" by the fact what it
is. A message sent to a receiver. You ask a receiver about its state,
not the world around it. So "do you" actually makes more sense than
asian/western grammar as an explanation, imho.

You might be right. But in any case, I'm guessing at least 40% of
programmers use plurals instead of collective nouns (i.e. lions
instead of pride) -- especially in databases (90% plural morbidity
there) -- then the use of start_with makes perfect sense. Whether it
really is a spoken language artifact or not is irrelevant, I guess, so
I apologize for bringing up that correlation.

Todd
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top