Forum: Ruby Check for two strings

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Newb N. (Guest)
on 2009-01-29 13:53
Is this possible to check for two strings.
i want to check whether these two params exits i want to proceed the
process
i get two strings through form
search_string_1 = params[:first_name]
search _string_2 = params[:second_name]
if folder_name.include?(search_string_1)(search_string_2)

end

Any helps pls
Robert K. (Guest)
on 2009-01-29 14:09
(Received via mailing list)
2009/1/29 Newb N. <removed_email_address@domain.invalid>:
> Is this possible to check for two strings.
> i want to check whether these two params exits i want to proceed the
> process
> i get two strings through form
> search_string_1 = params[:first_name]
> search _string_2 = params[:second_name]
> if folder_name.include?(search_string_1)(search_string_2)

What kind of test do you want? Do you want both or at least one of them?

[search_string_1,search_string_2].all? {|s| folder_name.include? s}
[search_string_1,search_string_2].any? {|s| folder_name.include? s}

Cheers

robert
Newb N. (Guest)
on 2009-01-30 05:19
i have tried your code.
but it gives me argument error

[search_string_1,search_string_2].all? {|s| sub_folder_name.include? s}

pls help me
Thanks
This topic is locked and can not be replied to.