An agricultural machine (1) for working grass, hay or other crops on the field, comprises a frame (2), a rake member arm (6) mounted on the frame (2), and a rake member (7). The rake member (7) comprises a centre body (8) rotatably mounted on the rake member arm (6), at least one rake element arm (6) extending from the centre body (8), and one or more rake elements (10) mounted on the rake element arm (6). The rake element arm (6) comprises a first arm part (12) and a second arm part (13), which are pivotally connected to each other between a working position and a transport position. The rake member (7) comprises a locking device for locking the first arm part (12) with respect to the second arm part (13). The locking device comprises a locking pin (24) movably mounted on the first arm part (12) between a locking position and a releasing position. The locking device comprises a first slot (27) and second slot (31) which are mounted on the second arm part (13). The first slot (27) is arranged to receive the locking pin (24) in the locking position when the first arm part (12) and the second arm part (13) are positioned in the working position to lock the first arm part (12) with respect to the second arm part (13) in the working position. The second slot (31) is arranged to receive the locking pin (24) in the locking position when the first arm part (12) and the second arm part (13) are positioned in the transport position to lock the first arm part (12) with respect to the second arm part (13) in the transport position.