0

I was wondering what is the difference between 3 ways of reaching the resId in Kotlin if there is any. I was trying to find some simple answer but couldn't find any.

Ways:

1) resources.getString(R.string.ticketDetailsContactFragment_cannot_send_email)

2) getString(R.string.ticketDetailsContactFragment_cannot_send_email)

3) R.string.ticketDetailsContactFragment_cannot_send_email

Example:

Toast.makeText(context, R.string.example, Toast.LENGTH_LONG).show()
Rahul Singh Chandrabhan
  • 2,531
  • 5
  • 22
  • 33
P.Juni
  • 2,365
  • 14
  • 26
  • 1
    Case 3 is not relevant. It's just that makeText has an overload that accepts an int instead of a string – Tim Oct 11 '18 at 09:34

1 Answers1

2

The only difference is that resources.getString(R.string.ticketDetailsContactFragment_cannot_send_email)

and

getString(R.string.ticketDetailsContactFragment_cannot_send_email)

will return a String

instead R.string.ticketDetailsContactFragment_cannot_send_email return its resId (int value)

Lorenzo Vincenzi
  • 1,153
  • 1
  • 9
  • 26
Manohar
  • 22,116
  • 9
  • 108
  • 144