I think I can try to help with this, though the terminology might not be 100% as I’m coming from Python programming.
Let’s set up some example code as the explanation depends on the data type:
struct User{
address id;
uint balance;
}
mapping(uint => User) users;
Here we have a custom data type, User. It contains two attributes - ID (which corresponds with an address) and balance (a positive whole number).
The mapping creates a dictionary of multiple entries, all of which are individual User data types so must contain those two attributes.
Now first we use [] to access a particular entry in the dictionary. You can think of [] as always looking something up:
// dictionaryName[dataToLookup]
users[msg.sender]
This will look up the address of the active user in the mapping to find the ID and balance associated with that one record in the dictionary.
We can then access those individual attributes by using . and adding the attribute name:
users[msg.sender].balance
…will access only the balance of the active user and:
users[msg.sender].id
…will return only the ID of the user (which in this instance is pointless as it’s just the address, which we already have access to using msg.sender)
I’ve found while learning it can help to assign multiple steps like this to variables to break them down, eg:
address activeUser = users[msg.sender]
uint activeUserBalance = activeUser.balance
Similarly, msg.sender accesses the sender attribute of the msg object.
The other thing using . can do is access a method associated with an object. A method runs an existing function specific to that object to make a change. It looks different because it always has brackets after it:
// object.methodToApply()
A method may or may not need additional input to run
// object.methodTo Apply()
// or
// object.attribute.methodToApply(data)
msg.sender.transfer(amount)
Here the method transfer() is being applied to the attribute sender from the object (or data type) msg. The method requires additional data as without that input it can’t be used. This is fed in as the variable ‘amount’.
I hope that helps to make some sense of it a bit.