Preheat the oven to 350°F (175°C). Grease an 8-inch (20 cm) loaf pan and line it with parchment paper, leaving an overhang on the sides for easy removal. In a small bowl, combine the milk and white vinegar or lemon juice. Let it sit for about 10 minutes until slightly curdled.
Add the castor sugar, light brown sugar, vegetable oil, and vanilla extract to the milk mixture. Whisk until well combined.
In a separate bowl, whisk together the all-purpose flour, baking powder, baking soda, cinnamon, and salt. Add the dry ingredients to the wet ingredients and mix just until combined. Avoid overmixing, which can make the loaf dense.
Add the freshly grated carrots and gently fold them into the batter. Fold in the chopped walnuts if using.
Pour the batter into the prepared loaf pan and smooth the top. If you want the loaf to develop a more defined split along the top, score a shallow line down the center of the batter using the tip of a knife.
Bake for roughly 45 min or until firm to touch.
Let the loaf cool in the pan before carefully lifting it out and transferring it to a wire rack. Cool completely before adding the cream cheese icing.