layoutInflater vs inflater

This may have been asked before. Android book 5th edition. Chapter 9 on Fragments. The onCreateView function for the CrimeListFragment is defined as this:

 override fun onCreateView(
 inflater: LayoutInflater,
 container: ViewGroup?,
 savedInstanceState: Bundle?
 ): View? {
 binding =
 FragmentCrimeDetailBinding.inflate(layoutInflater, container, false)
 return binding.root
 }

Whereby the inflater that is passed as parameter is ignored and the code uses the layoutInflater member variable.

Later in next chapter, the CrimeListFragment is initialized as follows:

 override fun onCreateView(
 inflater: LayoutInflater,
 container: ViewGroup?,
 savedInstanceState: Bundle?
 ): View? {
 _binding = FragmentCrimeListBinding.inflate(inflater, container, false)
 return binding.root
 }

This fragment uses the inflater passed in instead of referencing the layoutInflater member variable.

So when do we inflate with the inflater passed in vs the layoutInflater of the Fragment class itself? What are the differences between these two inflaters?

You found one of my typos in the book. You should always use the inflater. That code listing in chapter 9 is incorrect.