Does Ruby have a string.startswith(“abc”) built in method?

后端 未结 4 1157
轻奢々
轻奢々 2020-12-23 12:41

Does Ruby have a some_string.starts_with(\"abc\") method that\'s built in?

4条回答
  •  心在旅途
    2020-12-23 13:30

    It's called String#start_with?, not String#startswith: In Ruby, the names of boolean-ish methods end with ? and the words in method names are separated with an _. Not sure where the s went, personally, I'd prefer String#starts_with? over the actual String#start_with?

提交回复
热议问题