Error : expected body of lambda expression .. (what is Lambda ???)

Just start learning CS106B , Error messages telling me something wrong with these 3 lines.

" Error : expected body of lambda expression "

string key = aToken.substr([i],1);


else {myMap[aToken.substr([i],1)] +=1};

int main() {

TokenScanner myTK;
myTK.setInput("Sven is Pro Moo Noob <naja>");
Map <string ,int> myMap;
    string aToken = myTK.nextToken();
    for(int i=0;i<= int(aToken.size());i++){
        string key = aToken.substr([i],1);
        else {myMap[aToken.substr([i],1)] +=1};
    cout << aToken << endl;
cout<< myMap.toString() << endl;
return 0;


Lambda expression is expression that usually takes form:

[capture list](parameters) {function body}

When compiler notices your [i] it expects that it's beginning of lambda expression. There is no reason to wrap numbers in square brackets in your case.

Lambda expressions allow in-line construction of functor objects with anonymous class. See: What is a lambda expression in C++11?

Need Your Help

Default release lint vs. gradle lint task

android android-studio gradle android-gradle lint

By default lint is enabled for release builds in gradle. Without the

Concat ReactElements to render

javascript reactjs

I have an If component in React that is very straightforward: