Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do 'starts_with' and 'start_with' have the same function in Ruby?

Apparently they are giving me the same output on any input like

"Ruby is red".start_with?("Ruby")

or

"Ruby is red".starts_with?("Ruby")

both are giving the same result.

like image 773
smaug Avatar asked Jan 22 '16 11:01

smaug


1 Answers

Before Ruby added String#start_with? as part of the core library, Rails' Active Support implemented the String#starts_with? method. Now it's just an alias kept for backwards compatibility.

So yes - they do the same thing, the first one comes from Ruby, the second one - from Rails.

like image 135
ndnenkov Avatar answered Nov 14 '22 16:11

ndnenkov