Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEmilio Meira
11,059 PointsProblems on the Linq query
I'm not sure what I'm doing wrong here, guys. The return is not matching the correct contains.
using System.Collections.Generic;
using System.Linq;
namespace Treehouse.CodeChallenges
{
public static class ContainsAnyExtension
{
public static bool ContainsAny(this string source, IEnumerable<string> stringsToMatch)
{
return stringsToMatch.Any(b => b.Contains(source));
}
}
}
1 Answer
Steven Parker
231,248 PointsIt looks like your arguments are reversed.
Remember, you're trying to see if any of the strings to match can be found in the source. So instead of b.Contains(source)
, you probably meant to write source.Contains(b)
.
Emilio Meira
11,059 PointsEmilio Meira
11,059 PointsArrrgghhh! You're so right! Thanks, man! :D