Item does not have an id

Does anyone know why the item is not returning the item's id value?


Example:

Code:
class Window_Help < Window_Base
  def set_item(item)
    p item.id #this is an error
    set_text(item ? item.description : "")
  end
end

It will give an error saying the item's id is not available. I wonder why.
You can set the item to nil and it'll clear the window's text. Nil does not have an 'id' property.
I see, that's probably the reason why it doesn't have anything after. When I print item, it says its an item with all the properties inside, but once I print that specific property it gives an error. But if it is already nil, why does item.description work?
Are you sure your item is properly formed? Like when you print out the item itself to the console (via p item.inspect), does it have an ID property, and is it an object class you expect it to be? If it doesn't have an ID field in the output of inspect, then something is wrong with your object. You will be able to see the class of the object, though, so please ensure that it is a type that is expected to be there.
Yes, it does.


BSLYnsA.jpg



So when I do item.id it should print me the id, I wonder why that's not working in this case.
Does that particular item cause the issue?
Somehow I solved the issue. The items are nil at the beginning, so I just have to set it that if its not equal to nil before I display it.
Well yeah, when the windows are created, the item is set to nil because it has no item. 

Original thread: https://forums.rpgmakerweb.com/threads/item-does-not-have-an-id.55570/