How to filter integer value based on string parameter input on list on kotlin?

49
December 02, 2020, at 6:20 PM

I am trying to filter an object type list based on a string value which is working fine, but now I need to filter based on an integer attribute of the objects on the list.

Say the object.name is "name", so when I start typing just "na" the filters works properly, but for the integer filter I cannot figure it out. It just filters when the user inputs the entire number.

return objectList.filter { it.name.contains(filter) || it.pCode == filter.toInt() }

I know that the way is comparing "==" only returns when is equal, but I do not know something like contains but for numbers.

Answer 1

Try this

it.pCode.toString().contains(filter) 
READ ALSO
execute php Shortcode on button click

execute php Shortcode on button click

I am trying to execute a php shortcode on button click but that is not running

38
Python uncatchable IOError [Errno 32] Broken pipe from Popen within Pool

Python uncatchable IOError [Errno 32] Broken pipe from Popen within Pool

I have a Python 27 code which is running two piped suprocess Popens with multiprocessing Pool as follows

58
Best way to store user notification prefrences in database

Best way to store user notification prefrences in database

I want to store user notification preferencesI do it like this:

54
MailGun results in 401 forbidden using nodeJs

MailGun results in 401 forbidden using nodeJs

I am trying to send an email using mailgun and nodejsI took the code MailGun provides you and added my domain name and api key:

47