The gerund always has the same function as a noun.
A gerund can be the subject in the sentence. Examples:
- Walking is good for you.
A gerund can be an object in the sentence. Examples:
- I like walking in the park.
A gerund after prepositions
After prepositions we normally use a gerund. Examples:
- Can you sneeze without opening your mouth?
- She is good at painting.
- I was the fastest at climbing the rope.
- What about going out tonight?
A gerund after certain specific verbs. Examples:
- I like cooking.
- He enjoys walking.
- They hate milking cows.
- I can imagine drifting away in a balloon.
A gerund in compound nouns. Examples:
- I took her to her driving lessons.
- We are going to the swimming pool.
- I am good at rope climbing.