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 trial

Android Testing in Android Unit Testing The First Test

In MainActivity, onEditorAction() takes 3 arguments, but why does Ben input 1 argument and it works?

Am I missing something?

2 Answers

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

They're actually two different things. In MainActivity, we're setting up an OnEditorActionListener which requires us to override its onEditorAction method. On the other hand, in our test we're just calling the onEditorAction method directly.

Oh, I see. You overrided the method which means the original method is there. Thank you Are you also thinking about updating Android Data Persistent course? It is outdated and the worst problem is that sample files are too old to be workable.

Ben Deitch
Ben Deitch
Treehouse Teacher

Yep, it's on our list. Though I didn't know about the sample files; thanks for passing that on!

Sadly, I'm no Android developer, and I'm new to Java, but I do know that almost all languages that support functions can have default values for arguments.

I didn't check the video so I'm not sure if this is the answer, but I can tell you that probably Ben used a default argument. When you define a function, you can assign a value to an argument inside the function definition. This value is used if you don't specify the argument when you call the function.


Maybe Ben used a default argument!

I hope this helps. ~Alex