suffix
: This is the file extension. If the suffix
is present, then the file name will be returned with its suffix
removed.
# create some file namesfn1 = "main.rb"fn2 = "test.js"fn3 = "test.txt"fn4 = "test.py"# use the basename() without suffixputs File.basename(fn1) # main.rbputs File.basename(fn2) # test.js# use the basename() with suffixputs File.basename(fn3, ".txt") # testputs File.basename(fn4, ".py") # test