Skip to main content Besuchen Sie uns auf der TDX in San Francisco oder bei Salesforce+ vom 5. bis 6. März, um die Entwicklerkonferenz für die Ära der AI-Agenten zu erleben. Jetzt registrieren.

#Trailhead Challenges2.397 diskutieren mit

Hands-on challenges are the “secret sauce” of Trailhead. Before searching for solutions to superbadge challenges, review the Salesforce Certification Program Agreement and Policies.

I am unable to complete this Trailhead Module: Get Hands-On with an Iterable Variable in For Loops, because I keep getting this error message: "The constructor MyIterable should accept parameter of type List<String>."

 

Here's my MyIterable Class with its constructor accepting the correct type of parameter:

 

public class MyIterable implements Iterable<String> {    private List<String> strings;    public MyIterable(List<String> strList) {        strings = strList;        strings.iterator();    }    public Iterator<String> iterator() {      return strings.iterator();   }}

 

#Trailhead Challenges

7 Antworten
  1. 12. Dez. 2024, 22:28

    Hi @Edward Dalton,

    • You need to assign strings (In constructor, It should be strings not strList) to strings class variable. Use this keyword.
    • You should replace strings = strList; with this.strings = strings;
    • In constructor remove strings.iterator();

    Code should be like this -

    public class MyIterable implements Iterable<String> {

    private List<String> strings;

    public MyIterable(List<String> strings) {

    this.strings = strings;

    }

    public Iterator<String> iterator() {

    return strings.iterator();

    }

    }

0/9000

I am trying to complete my Winter 25 Platform Developer I maintenance, and keep getting the following error when trying to complete the Challenge.

"Challenge not yet complete in Brave Moose Playground

We can’t find The Annotation @IsTest for method ‘testIterableForLoop’. "

 

I have tried to correct this multiple times by creating a new playground, but the same error persists.  As you can see below the @IsTest annotation is in my code below:

@IsTest

public class MyIterableTest {

@IsTest

    public static void testIterableForLoop () {

        List <String> strings = new List<String> {'Hello', 'World'};      

            MyIterable myIterable = new MyIterable(strings);

        for (String str: myIterable)

        {

            System.debug(str);

        }  

    }

}

 

Any help and Insight would be appreciated

16 Antworten
  1. 23. Dez. 2024, 16:09

    Working with Support, they were able to resolve the issue.  If you get this issue, I suggest opening a salesforce case, as I had to create a user for them in order for it to be resolved.  

0/9000

Getting issue in validating the hands on challenge with the below error: The constructor MyIterable should accept parameter of type List<String>.

 

Here's my code snippet:

public class MyIterable implements Iterable<String>{    private List<String> strings;    public MyIterable(List<String> strings){        this.strings= strings;    }    public Iterator<String> iterator() {      return strings.iterator();   }}

 

#Trailhead Challenges

0/9000

Hello,

That's my code but i still have the following message :

"The constructor MyIterable should accept parameter of type List<String>."

Can someone help me please ?

public class MyIterable implements Iterable<String> {

private List<String> strings;

public MyIterable (List<String> strings)

{

this.strings = strings;

}

public Iterator<String> iterator() {

return strings.iterator();

}

}

#Trailhead Challenges

7 Antworten
  1. Eric Burté (DEVOTEAM) Forum Ambassador
    19. Dez. 2024, 17:39
0/9000

I am not able to complete my maintenance certification of the challenge relating to "Get Hands-On with an Iterable Variable in For Loops ". As I tried completing the challenge trail with following the instructions, I am receiving following error.

The constructor MyIterable should accept parameter of type List<String>

The output in the test run I am getting the proper result. It looks like there is an issue with the playground itself. 

Is anybody else facing the same issue?

 

#Trailhead Challenges  #Trailhead-challenges

0/9000

I'm receiving "The parameter List<String> cannot be null." trying to complete "Get Hands-On with an Iterable Variable in For Loops " challenge even though the result is as expected and requested in the challenge.  Tried to validate for completion after 2 days. I'm still getting the same output. testIterableForLoop is producing the required result.

#Trailhead Challenges  #Salesforce Developer

0/9000

ハンズオンに従ってChallengeに挑戦しましたが合格になりません。

MyIterableクラスおよびMyIterableTestをChallengeの指示通りに作成し、New Runを実施したところ期待のデバッグ結果が得られました。

しかしながらChallengeを確認すると添付の「コンストラクター MyIterable は List 型 <String> のパラメーターを受け入れる必要があります。」のエラーとなり解決策が不明です。

 

これはTrailHead側のエラーなのか私のエラーなのか不明です。

有識者による助言を求めます。

 

#Trailhead Challenges

6 Antworten
0/9000

Hi All,

I encountered this issue and attempted all recommended solutions, but they were unsuccessful.

Please review and advise.

Thanks.

 

Challenges:

 

https://trailhead.salesforce.com/content/learn/modules/platform-developer-i-certification-maintenance-winter-25/get-hands-on-with-iterable-variable-in-for-loops?trail_id=maintain-your-salesforce-certifications

 

@isTest

 

public class MyIterableTest {

    @isTest

 

    private static void testIterableForLoop() {

        Test.startTest();

 

        List<String> strings = new List<String> {'Hello', 'World'};

 

        MyIterable myIterable = new MyIterable(strings);

 

        for (String str : myIterable) {

 

            System.debug(str);

 

        }

        Test.stopTest();

 

    }

 

}

 

#Trailhead Challenges

0/9000

Well, this is annoying. I've implemented the code. It works perfectly. It matches other examples of people who have succeeded. But no matter what I do (even introducing other errors), I get the error:

 

Error "The parameter List<String> cannot be null"

 

So either I am missing something incredibly embarrassing and obvious, or the hands-on test is horribly broken. Right now, I'm thinking the latter - so if someone at Salesforce could look into it, I'd appreciate it.

 

public class MyIterable implements Iterable<String> {

 

    private List<String> strings;  

    

    public MyIterable(List<String> strings) {

       this.strings = strings;

    }

    

    public Iterator<String> iterator() {

      return strings.iterator();

   }

}

 

@istest

public class MyIterableTest {

 

    @IsTest

    static void testIterableForLoop() {

        List<String> strings = new List<String>{'Hello', 'World'};

        

        MyIterable testIterable = new MyIterable(strings);

        

        for(String str: testIterable)

        {

            System.debug(str);

        }

}

    

}

 

#Trailhead Challenges

7 Antworten
  1. 25. Dez. 2024, 15:36

    For anyone running into this - I was right, it was a problem with the validation. They opened a case and the resolution was as follows:

    " We've thoroughly reviewed it in your org and can confirm that everything has been implemented according to the badge requirements. It appears this may be an intermittent issue that occurred while verifying the challenge. "

    I tried again per their instructions, and the validation succeeded.

    So if you run into this problem, wait 24 hours and try again.

0/9000